forward
Method to create connection between units in a declarative way. Sends updates from one set of units to another
#
FormulaeArguments
from
(Unit | Unit[]): Source of updates. Forward will listen for changes of these units- if an Event is passed,
to
will be triggered on each event trigger and receives event argument - if a Store is passed,
to
will be triggered on each store change and receives new value of the store - if an Effect is passed,
to
will be triggered on each effect call and receives effect parameter - if an array of units is passed,
to
will be triggered when any unit infrom
array is triggered
- if an Event is passed,
to
(Unit | Unit[]): Target for updates.forward
will trigger these units with data fromfrom
Returns
Subscription: Unsubscribe function. It breaks connection between from
and to
. After call, to
will not be triggered anymore.
since
Arrays of units are supported since effector 20.6.0
#
Recommendation- Arrays can contain different type of units, but their data types should match
- Use subscription with caution, because it breaks static connections and makes debug harder