Skip to content

effector/no-domain-unit-creators

Disallow calling domain methods like .createEvent(), .createStore(), and .createEffect() to create units. These method-based APIs are difficult to parse with AST-aware plugins and tools, leading to compatibility issues.

Instead, prefer to use standard factory functions from effector package and provide the domain parameter. This is compatible with AST-based tools and is generally more consistent with other Effector API.

ts
import { createDomain } from "effector"

const domain = createDomain()

// 👎 hard to parse & work with
const event = domain.createEvent() 
const $store = domain.createStore("value") 
const effectFx = domain.createEffect() 

// 👍 clean and consistent
const event = createEvent({ domain }) 
const $store = createStore("value", { domain }) 
const effectFx = createEffect({ domain }) 

Last updated:

Released under the MIT License