interval
interval({ timeout, start, stop })
Motivation
Creates a dynamic interval with events to start, stop interval, and handle tick.
Formulae
- When
start
is triggered,tick
will betriggered
eachtimeout
ms - Till
start
is triggered, untilstop
is triggered,isRunning
will betrue
- After
stop
is triggeredtick
won’t be triggered, untilstart
is run again
Arguments
timeout
(number | Store<number>)
- timeout for eachtick
runstart
(Event<any>)
- start triggeringtick
. Double trigger withoutstop
call, do nothing.stop
(Event<any>)
- stop triggeringtick
. Double trigger withoutstart
call between them, do nothing.leading
(boolean)
- Allows runningtick
whenstart
is triggered.trailing
(boolean)
- Allows runningtick
whenstop
is triggered, it will be final call oftick
.
Returns
- An object of event
tick
and storeisRunning
tick
(Event<void)
- the event is run on eachtimeout
ms afterstart
trigger untilstop
triggerisRunning
(Store<boolean>)
- the store containsfalse
untilstart
is triggered, next untilstop
triggered the store will betrue
.
Example
@@trigger
protocol
interval
supports @@trigger
protocol. It means that you can use interval
whatever you can use trigger
with, just do not pass start
and stop
options.
For example, you can use interval
to refresh data in the Query from the library Farfetched using @@trigger
protocol.