ubu
04/09/2018, 12:02 PMstate1 -> state2 -> state1 -> state2 -> state1 -> state2 -> ...
When there’s no event within 3 seconds, restore default state (state1). How would I do that?
Any help would be appreciated.leolima
04/09/2018, 2:11 PMubu
04/09/2018, 2:51 PMleolima
04/09/2018, 4:16 PMonly emit an item from an Observable if a particular timespan has passed without it emitting another itemPerhaps if you share some code, we can understand your problem properly
arekolek
04/09/2018, 4:29 PMleolima
04/09/2018, 4:37 PMubu
04/09/2018, 4:46 PMon
and off
. If user stops pressing the button within the timespan of 3 seconds, and current state is on
observable will emit default value (off
).
It’s a bit verbose, sorry.
So, basically, I have three events:
1) on
2) off
3) nothing
(if the last state was off
and there’s at least 3 seconds that user does not press the button, emit a default value = off
)ubu
04/09/2018, 4:58 PMSeri
04/09/2018, 7:59 PMSeri
04/09/2018, 8:02 PMon
and off
events whenever the state is toggled
* Whenever on
is toggled, also send out a throttled event with a three second timeout
* That 3s timer will be interrupted and replaced by any additional on
events, by the definition of the throttle operator
* When the throttle expires, emit an off
eventubu
04/09/2018, 8:14 PMSeri
04/09/2018, 8:22 PM.debounce().subscribe()
to the end of your chain to get the behavior I describedubu
04/09/2018, 9:53 PMstate
in second subscription in each of the examples.