當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。