effector-root
v1.4.0
Published
Units in the root domain for testing and SSR support
Downloads
13,811
Readme
effector-root
Do not depend on this package in your libraries!
Motivation
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.
Usage
Replace all imports of
effector
toeffector-root
. You can do it by yourself or with babel pluginTo retrieve our app root domain we need just to import it.
import { root, createEvent, attach, fork } from 'effector-root';
Create React App and macros support
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
Compat
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
How to auto replace all imports of effector to effector-root using babel plugin
- Install babel-plugin-module-resolver
- Add to plugins:
['module-resolver', { alias: { effector: 'effector-root' } } ]