How to use the effector/graphite/typedef.Step.seq 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 / store / StepBox.js View on Github external
return Cmd.run(data)
}
export function emit(
  subtype: 'event' | 'effect',
  fullName: string,
  runner: (ctx: any) => any,
) {
  return Cmd.emit({subtype, fullName, runner})
}
export function update(store: Ref) {
  return Cmd.update({store})
}
export class StepBox {
  depth: number = 0
  mod: 'seq' | 'par' = 'seq'
  /*::;+*/ prime = Step.seq([])
  current = this.prime
  modeSeq(): StepBox<'seq'> {
    if (this.mod === 'par') {
      const {prime} = this
      const next = Step.seq([])
      prime.data.push(next)
      this.current = next
    }
    this.mod = 'seq'
    return /*::toSeq(*/ this /*::)*/
  }
  modePar(): StepBox<'par'> {
    if (this.mod === 'seq') {
      const {prime} = this
      const next = Step.multi([])
      prime.data.push(next)
github zerobias / effector / src / event / concreteFabric.js View on Github external
event(args: {fullName: string, runner: Function}): GraphiteMeta {
    const unit = Cmd.emit({
      subtype: 'event',
      fullName: args.fullName,
      runner: args.runner,
    })
    const cmd = Step.single(unit)
    const nextSteps = Step.multi([])
    const stepFull = Step.seq([cmd, nextSteps])
    const graphite = {next: nextSteps, seq: stepFull}
    return graphite
  },
  prependEvent(args: {|
github zerobias / effector / src / store / StepBox.js View on Github external
modeSeq(): StepBox<'seq'> {
    if (this.mod === 'par') {
      const {prime} = this
      const next = Step.seq([])
      prime.data.push(next)
      this.current = next
    }
    this.mod = 'seq'
    return /*::toSeq(*/ this /*::)*/
  }
  modePar(): StepBox<'par'> {
github zerobias / effector / src / event / concreteFabric.js View on Github external
parentGraphite: GraphiteMeta,
  |}): GraphiteMeta {
    const {fn, graphite, parentGraphite} = args
    const unitCompute = Cmd.compute({
      reduce(_, newValue, ctx): mixed {
        return fn(newValue)
      },
    })
    const unitFilter = Cmd.filter({
      filter(result, ctx: TypeDef<'emitCtx', 'ctx'>): boolean {
        return result !== undefined
      },
    })
    const cmdCompute = Step.single(unitCompute)
    const cmdFilter = Step.single(unitFilter)
    const stepFull = Step.seq([cmdCompute, cmdFilter, graphite.seq])
    parentGraphite.next.data.push(stepFull)
    return graphite
  },
}