How to use the effector.createNode function in effector

To help you get started, we’ve selected a few effector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / effector / src / effector / fork.js View on Github external
}
  const completeInitPhase = () => {
    if (fxCount === 0) {
      fxID += 1
      tryCompleteInitPhase && tryCompleteInitPhase()
    }
  }
  const effects = []
  const finalizers = []
  for (let i = 0; i < clones.length; i++) {
    const node = clones[i]
    if (node.meta.unit !== 'effect') continue
    effects.push(node)
    finalizers.push(node.scope.runner.scope.anyway)
  }
  const onStart = createNode({
    node: [
      step.compute({
        fn() {
          fxCount += 1
          fxID += 1
        },
      }),
    ],
    parent: effects,
  })
  const onEnd = createNode({
    node: [
      step.run({
        fn() {
          fxCount -= 1
          completeInitPhase()
github zerobias / effector / src / effector / fork.js View on Github external
const clones = list.map(({seq, next, meta, scope, family}) => {
    const result = createNode({
      node: seq.map(step => ({
        id: step.id,
        type: step.type,
        data: Object.assign({}, step.data),
        hasRef: step.hasRef,
      })),
      child: [...next],
      meta: Object.assign({}, meta),
      scope: Object.assign({}, scope),
    })
    result.family = {
      type: family.type,
      links: [...family.links],
      owners: [...family.owners],
    }
    return result
github zerobias / effector / src / effector / fork.js View on Github external
if (node.meta.unit !== 'effect') continue
    effects.push(node)
    finalizers.push(node.scope.runner.scope.anyway)
  }
  const onStart = createNode({
    node: [
      step.compute({
        fn() {
          fxCount += 1
          fxID += 1
        },
      }),
    ],
    parent: effects,
  })
  const onEnd = createNode({
    node: [
      step.run({
        fn() {
          fxCount -= 1
          completeInitPhase()
        },
      }),
    ],
    parent: finalizers,
  })
  if (start) {
    launch(find(start), ctx)
  }
  isSyncComplete = true
  completeInitPhase()
  return defer.req