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, requiredvaluesOptional object with either a mapping from store sids (babel-plugin is required to allowsidgeneration) to store values or a Map where keys are Store objects and values contains initial store valuehandlersOptional object with either a mapping from effect sids (babel-plugin is required to allowsidgeneration) to effect handlers or a Map where keys are Effect objects and values contains handlers
Returns
Scope object containing information about cloned domain
Example#
Create two instances with independent counter state
Support Map in values#
since
effector 20.11.0
Support change effects#
since
effector 20.16.0
Support for handlers to fork to change effect handlers for forked scope (useful for testing)