reshape
result = reshape({ source, shape })
Motivation
This method allows to create many stores from single store at once. It useful when you want to read many properties from object to different stores.
Formulae
- Call each function in
shape
object with data fromsource
, and create store with the same name as key inshape
- If function in
shape
returnsundefined
, the same store will containnull
, because store cannot containundefined
.
Arguments
source
(Store
) — Source store, data from this unit passed to each function inshape
shape
({ [key: string]: (payload: T) => any }
) — Object of functions. Function receives payload ofsource
as single argument, should return any value.
Returns
result
({ [key: string]: Store<any> }
) — Object of stores, that created with the same structure asshape
, with data from passed functions