当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript PropagateTask.event方法代码示例

本文整理汇总了TypeScript中@tempest/core.PropagateTask.event方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PropagateTask.event方法的具体用法?TypeScript PropagateTask.event怎么用?TypeScript PropagateTask.event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@tempest/core.PropagateTask的用法示例。


在下文中一共展示了PropagateTask.event方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it ('should end a stream when a signal emits', (done) => {
    const signal = new Stream<number>({
      run (sink: Sink<number>, scheduler: Scheduler) {
        const task = scheduler.delay(90, PropagateTask.event(100, sink))
        return {
          dispose () {
           scheduler.cancel(task)
          }
        }
      }
    })

    const source = new Stream<number>({
      run (sink: Sink<number>, scheduler: Scheduler) {
       const task = scheduler.periodic(50, PropagateTask.event(0, sink))

        return {
          dispose () {
            scheduler.cancel(task)
          }
        }
      }
    })

    const stream = endWhen(signal, source)
    const expected = [0, 0]

    stream.subscribe((x: number) => {
      assert(x === expected.shift())
    }, done, (y) => {
      assert(y === 100)
      done()
    })
  })
开发者ID:TylorS,项目名称:tempest,代码行数:34,代码来源:index.ts

示例2: it

  it ('should sample another streams values', function (done) {
    const sampler = new Stream<number>({
      run (sink: Sink<number>, scheduler: Scheduler) {
        scheduler.delay(100, PropagateTask.event(0, sink))
        scheduler.delay(250, PropagateTask.event(0, sink))
        scheduler.delay(260, PropagateTask.end(0, sink))
        return {
          dispose () {
            return void 0
          }
        }
      }
    })

    const stream = new Stream<number>({
      run (sink: Sink<number>, scheduler: Scheduler) {
        sink.event(scheduler.now(), 1)
        setTimeout(() => {
          sink.event(scheduler.now(), 2)
        }, 150)
        setTimeout(() => {
          sink.event(scheduler.now(), 3)
        }, 190)
        return {
          dispose () {
            return void 0
          }
        }
      }
    })

    const expected = [1, 3]

    sample(sampler, stream).subscribe((x: number) => {
      assert(x === expected.shift())
    }, done, (x) => {
      assert(x === 3)
      done()
    })
  })
开发者ID:TylorS,项目名称:tempest,代码行数:40,代码来源:index.ts

示例3: it

  it ('should flatten a higher order stream into a single order stream', (done) => {
    const stream = Stream.of(1, 2, 3)
    const higherStream = new Stream<Stream<number>>({
      run (sink: Sink<Stream<number>>, scheduler: Scheduler) {
        const task = scheduler.asap(PropagateTask.event(stream, sink))
        const task2 = scheduler.asap(PropagateTask.end(void 0, sink))
        return {
          dispose () {
            scheduler.cancel(task)
            scheduler.cancel(task2)
          }
        }
      }
    })

    const s = flatten(higherStream)
    const expected = [1, 2, 3]

    s.subscribe((x) => {
      assert(x === expected.shift())
    }, done, () => done())
  })
开发者ID:TylorS,项目名称:tempest,代码行数:22,代码来源:index.ts

示例4: next

 next (value: T) {
   defaultScheduler.asap(PropagateTask.event(value, this.source))
 }
开发者ID:TylorS,项目名称:tempest,代码行数:3,代码来源:index.ts


注:本文中的@tempest/core.PropagateTask.event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。