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


TypeScript rxjs-run.run函数代码示例

本文整理汇总了TypeScript中@cycle/rxjs-run.run函数的典型用法代码示例。如果您正苦于以下问题:TypeScript run函数的具体用法?TypeScript run怎么用?TypeScript run使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: it

  it('should allow effect to see one or many HTML outputs', function (done) {
    function app() {
      return {
        html: Rx.Observable.interval(150).take(3).map(i =>
          div('.test-element', ['Foobar' + i]),
        ),
      };
    }

    const expected = [
      '<div class="test-element">Foobar0</div>',
      '<div class="test-element">Foobar1</div>',
      '<div class="test-element">Foobar2</div>',
    ];

    function effect(html: string): void {
      assert.strictEqual(html, expected.shift());
      if (expected.length === 0) {
        done();
      }
    }

    run(app, {
      html: makeHTMLDriver(effect),
    });
  });
开发者ID:whitecolor,项目名称:cyclejs,代码行数:26,代码来源:html-render.ts

示例2: it

  it('should allow going back a route with type `go`', done => {
    function main(sources: {history: Observable<Location>}) {
      return {
        history: Observable.of<HistoryInput | string>('/test', '/other', {
          type: 'go',
          amount: -1,
        }),
      };
    }

    const {sources, run} = setup(main, {
      history: makeServerHistoryDriver(),
    });

    const expected = ['/test', '/other', '/test'];

    sources.history.skip(1).subscribe({
      next(location: Location) {
        assert.strictEqual(location.pathname, expected.shift());
        if (expected.length === 0) {
          done();
        }
      },
      error: done,
      complete: () => {
        done('complete should not be called');
      },
    });
    run();
  });
开发者ID:joeldentici,项目名称:cyclejs,代码行数:30,代码来源:rxjs.ts

示例3: setTimeout

    setTimeout(() => {
      assert.strictEqual(expectedDOMSinks.length, 4);

      // DOM then HTTP:
      Cycle.run(mainDOMThenHTTP, {
        HTTP: makeHTTPDriver(),
        DOM: domDriver,
      });
      setTimeout(() => {
        assert.strictEqual(expectedDOMSinks.length, 0);
        done();
      }, 4000);
    }, 4000);
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:13,代码来源:index.ts

示例4: it

  it('should create a location from ReplaceHistoryInput', (done) => {
    function main(sources: {history: Observable<Location>}) {
      return {
        history: Observable.of({type: 'replace', pathname: '/test'}),
      };
    }

    const {sources, run} = setup(main, { history: makeServerHistoryDriver() });

    sources.history.skip(1).subscribe({
      next (location: Location) {
        assert.strictEqual(location.pathname, '/test');
        done();
      },
      error: done,
      complete: () => { done('complete should not be called'); },
    });
    run();
  });
开发者ID:whitecolor,项目名称:cyclejs,代码行数:19,代码来源:rxjs.ts

示例5: main

  it('should not remember past responses when selecting', function(done) {
    this.timeout(4000);

    function main(_sources: any) {
      const test$ = of(null).pipe(
        delay(1000),
        mergeMap(() =>
          _sources.HTTP.select('cat').pipe(
            mergeAll(),
            map((res: any) => 'I should not show this, ' + res.text)
          )
        )
      );

      const request$ = of({
        category: 'cat',
        url: uri + '/hello',
      });

      return {
        HTTP: request$,
        Test: test$,
      };
    }

    function testDriver(sink: any) {
      sink.addListener({
        next: (s: any) => {
          console.log(s);
          done('No data should come through the Test sink');
        },
        error: (err: any) => {
          done(err);
        },
      });
    }

    globalRun(main, {
      HTTP: makeHTTPDriver(),
      Test: testDriver,
    });

    setTimeout(() => {
      done();
    }, 2000);
  });
开发者ID:,项目名称:,代码行数:46,代码来源:


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