I have an observable that I am subscribing on. This obsevable will be returning an object that has a property called ActivationType that can be set multiple times.
What I am trying to achieve is log a message whenever ActivationType is set to "Type1". However, if ActivationType is set to "Type2", log the message only once and wait for 30 seconds before logging again if ActivationType is "Type2".
So if I have:
myObservable
.Where(o => o.ActivationType == "Type1" || o.ActivationType == "Type2") //listen for types 1 and 2
.Throttle() // ??? somehow only throttle if we are currently looking at Type2
.Subscribe(Log); //log some stuff
I believe Throttle() is what I am looking for but am not sure how to trigger it conditionally.
Any suggestions?
Throttle
probably isn't what you want -Throttle
is much likeWindow
, in that it will trigger once at the end of each period (in your case 30 seconds), so any "Type2" events would be delayed until the end of each window. – Hebbe