Skip to content

effector 20.17.2

Choose a tag to compare

@zerobias zerobias released this 27 Jun 00:55
· 3644 commits to master since this release
a824b0f
  • Add effects created via attach to domain effects, allowing these effects to be called within other effects when using fork
import {createDomain, attach} from 'effector'
import {fork, allSettled} from 'effector/fork'

const app = createDomain()

const add = app.createEffect({handler: _ => _})

const count = app.createStore(2).on(add.doneData, (x, y) => x + y)

const addWithCurrent = attach({
  source: count,
  effect: add,
  mapParams: (params, current) => params + current,
})

const start = app.createEffect({
  async handler(val) {
    await addWithCurrent(val)
  },
})

const scope = fork(app)

await allSettled(start, {
  scope,
  params: 3,
})

console.log(scope.getState(count))
// => 7

Try it

  • Add validation for combine first argument which should be store, object with stores or array with stores PR #362 (thanks @doasync)