snapshot
result = snapshot({ source, clock, fn })
Motivation
This method allows to copy any store on optional trigger unit. It useful when you want to save previous state of store before some actions.
Formulae
- Call
fn
with data fromsource
whileclock
triggered, and create store with the value - If
fn
returnsundefined
, the update will be skipped.
Arguments
source
(Store
) — Source store, data from this unit passed tofn
clock
(Event
,Effect
,Store
) — Trigger unitfn
((value: T) => U)
— Transformation function
Returns
result
(Store
) — Copied store