effector-root

Units in the root domain for testing and SSR support

Usage no npm install needed!

<script type="module">
  import effectorRoot from 'https://cdn.skypack.dev/effector-root';
</script>

README

effector-root

Commitizen friendly Conventional Commits code style: prettier

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

  1. Replace all imports of effector to effector-root. You can do it by yourself or with babel plugin

  2. To 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 import import * 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 from effector-root/compat is not the same domain as from effector-root