fork
since
effector 21.0.0
Creates a fully isolated instance of application. The primary purpose of fork includes SSR (but is not limited to). Fork clones all the units and connections between them leading to completely independents copy of all logic defined within domain.
Arguments
domain
(Domain): Original domain to clone, requiredvalues
Optional object with either a mapping from store sids (babel-plugin is required to allowsid
generation) to store values or a Map where keys are Store objects and values contains initial store valuehandlers
Optional object with either a mapping from effect sids (babel-plugin is required to allowsid
generation) to effect handlers or a Map where keys are Effect objects and values contains handlers
Returns
Scope object containing information about cloned domain
#
ExampleCreate two instances with independent counter state
#
Support Map in valuessince
effector 20.11.0
#
Support change effectssince
effector 20.16.0
Support for handlers to fork to change effect handlers for forked scope (useful for testing)