Do not depend on this package in your libraries!
Sometimes we developed our apps and just afterwards start thinking about SSR and testing. For these purposes any effector app need to have root domain.
Usually we just manually update declarations. For example, from createEvent
to rootDomain.createEvent
. It takes time. effector-root provides you the possibility to have all units attached to the root domain without any manual actions.
-
Replace all imports of
effector
toeffector-root
. You can do it by yourself or with babel plugin -
To retrieve our app root domain we need just to import it.
import { root, createEvent, attach, fork } from 'effector-root';
Replace all imports of effector
to effector-root/macro
to automatically add sid:
import { root, createEvent, attach, fork } from 'effector-root/macro';
Note: babel-plugin-macros do not support
import * as name
, so Your importimport * as effector from 'effector-root/macro
won't work
You can easily use effector/compat
in your application with effector-root
, just:
import { root, createEvent, attach, fork } from 'effector-root/compat';
Note:
root
domain fromeffector-root/compat
is not the same domain as fromeffector-root