useUnit
Bind effector stores to solid reactivity system or, in the case of events/effects - bind to current scope to use in dom event handlers.
Only effector-solid/scope
version works this way, useUnit
of effector-solid
is no-op for events and does not require Provider
with scope.
useUnit(unit)
#
Arguments
Returns
(Function): Function to pass to event handlers. Will trigger given unit in current scope
#
ExampleuseUnit(store)
#
Arguments
store
Effector (Store)
Returns
Accessor which will subscribe to store state
#
ExampleuseUnit(shape)
#
Arguments
shape
Object or array of (Event or Effect or Store): Events or effects or stores as accessors which will be bound to the currentscope
Returns
(Object or Array):
- if event or effect: functions with the same names or keys as argument to pass to event handlers. Will trigger given unit in current scope Note: events or effects will be bound only if
useUnit
is imported fromeffector-solid/scope
- if store: accessor signals which will subscribe to the store state