restore(event, defaultState)
Creates a Store
from Event
Arguments
event
(Event)defaultState
(Payload)
Returns
(Store
)
Example
const event = createEvent('event')
const store = restore(event, 'default')
store.watch(state => console.log('state: ', state))
// state: default
// state: foo
event('foo')
restore(effect, defaultState)
Creates a Store
from Effect
Arguments
effect
(Effect)defaultState
(Done)
Returns
(Store
)
Example
const effect = createEffect('effect')
effect.use(() => Promise.resolve('foo'))
const store = restore(effect, 'default')
store.watch(state => console.log('state: ', state))
// state: default
// state: foo
effect()
restore(obj)
Creates an object with stores from object
Arguments
obj
(State)
Returns
(Store
)
Example
const obj = restore({
foo: 'foo',
bar: 0,
})
obj.foo.getState()
// 'foo'
obj.bar.getState()
// 0