effector icon indicating copy to clipboard operation
effector copied to clipboard

Rework `domain`-related APIs

Open igorkamyshev opened this issue 3 years ago • 1 comments

Proposal

Current domain-related APIs is a hard to parse by AST-awared plugins. It leads to some problems and races with other tools (e.g., https://github.com/effector/effector/issues/580, https://github.com/effector/effector/issues/482, https://github.com/effector/effector/issues/204). But, effector-react uses the different approach and doesn't have this issue.

const domain = createDomain()
const Gate = createGate({ domain })

I propose to add the new optional parameter to all creator-functions.

// old approach
const domain = createDomain()
const $domainStore = domain.createStore(null)

// new approach
const domain = createDomain()
const $domainStore = createStore(null, { domain });

In next major releases, we can deprecate domain.create*-calls.

What do you think, folks?

igorkamyshev avatar Dec 25 '21 08:12 igorkamyshev

Great idea! 👍 It should really improve developer experience

zerobias avatar Dec 26 '21 20:12 zerobias