reset({ clock, target })
Motivation
The method allow to reset many stores by a single line
- When
clock
is triggered, reset store/stores in target
to the initial value.
Arguments
clock: Unit<any> | Array<Unit<any>>
— Any kind of units is accepted (Store, Event, Effect).
target: Store<any> | Array<Store<any>>
— Each of these stores will be reset to the initial values when clock
is happened.
Example
Try it
Alternative
First variant is writing each reset by yourself:
There has another way — use domain:
reset({ target })
Motivation
The method allow to reset many stores by a single line with no clock
passing
- When
resetEvent
is triggered, reset store/stores in target
to the initial value.
Arguments
target: Store<any> | Array<Store<any>>
— Each of these stores will be reset to the initial values when resetEvent
is triggered.
Returns
resetEvent
(Event<void>)
— New event that reset store/stores in target
.
Example
Alternative
Write reset event by yourself: