tee<O2, O3> method

Conveyor<F, O3> tee<O2, O3>(
  1. Conveyor<F, O2> c2,
  2. Conveyor<Both<O, O2>, O3> t
)

Implementation

Conveyor<F, O3> tee<O2, O3>(Conveyor<F, O2> c2, Conveyor<Both<O, O2>, O3> t) => t.interpret<Conveyor<F, O3>>(
    (h, t) => produce(h, tee(c2, t))
    ,(side, recv) => side.direction == BothDirection.LEFT
        ? interpret(
        (o, ot) => ot.tee(c2, Try(() => recv(right(o))))
        ,(reqL, recvL) => consume(reqL, (ea) => recvL(ea).tee(c2, t))
        ,(e) => c2.kill<O3>().onComplete(() => halt(e)))
        : c2.interpret(
        (o2, ot) => tee(ot, Try(() => recv(right(o2))))
        ,(reqR, recvR) => consume(reqR, (ea) => tee(recvR(ea), t))
        ,(e) => kill<O3>().onComplete(() => halt(e)))
    ,(e) => kill<O3>().onComplete(() => c2.kill<O3>().onComplete(() => halt(e))));