當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript xstream.never函數代碼示例

本文整理匯總了TypeScript中xstream.never函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript never函數的具體用法?TypeScript never怎麽用?TypeScript never使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了never函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should allow listening to link clicks and change route', function(done) {
    setAdapt(x => x);
    const historyDriver = makeHistoryDriver();
    const sink = xs.never();
    const history$ = captureClicks(historyDriver)(sink);

    const sub = history$
      .compose(debounce(5))
      .drop(1)
      .subscribe({
        next: (location: Location) => {
          assert.strictEqual(location.pathname, '/test');
          sub.unsubscribe();
          sink.shamefullySendComplete();
          done();
        },
        error: err => {},
        complete: () => {},
      });

    const a = document.createElement('a');
    a.href = '/test';
    document.body.appendChild(a);

    setTimeout(() => {
      a.click();
    }, 10);
  });
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:28,代碼來源:common.ts

示例2: app

 function app(sources: TestSources) {
   return {
     other: concat(
       sources.other.take(6).map(x => String(x)).startWith('a'),
       xs.never(),
     ),
   };
 }
開發者ID:joeldentici,項目名稱:cyclejs,代碼行數:8,代碼來源:index.ts

示例3: main

 function main(sources: {whatever: StateSource<any>}) {
   assert.strictEqual(!!sources.whatever, true);
   assert.strictEqual(typeof sources.whatever, 'object');
   assert.strictEqual(typeof sources.whatever.stream, 'object');
   assert.strictEqual(typeof sources.whatever.select, 'function');
   assert.strictEqual(typeof sources.whatever.isolateSource, 'function');
   assert.strictEqual(typeof sources.whatever.isolateSink, 'function');
   return {whatever: xs.never()};
 }
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例4: app

 function app(_sources: TestSources) {
   return {
     other: concat(
       _sources.other
         .take(6)
         .map(String)
         .startWith('a'),
       xs.never()
     ),
   };
 }
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:11,代碼來源:setup.ts

示例5: driver

 function driver(sink: Stream<number>): Stream<any> {
   setTimeout(() => {
     sink.subscribe({
       next(x) {
         assert.strictEqual(x, expected.shift());
       },
       error() {},
       complete() {},
     });
   });
   return xs.never();
 }
開發者ID:joeldentici,項目名稱:cyclejs,代碼行數:12,代碼來源:index.ts

示例6: it

 it('should not accept a selector to an unknown element as input', function(done) {
   const sandbox = sinon.createSandbox();
   sandbox.stub(console, 'error');
   makeDOMDriver('#nonsenseIdToNothing')(xs.never());
   setTimeout(() => {
     sinon.assert.calledOnce(console.error as any);
     sinon.assert.calledWithExactly(
       console.error as any,
       sinon.match({
         message: 'Cannot render into unknown element `#nonsenseIdToNothing`',
       })
     );
     sandbox.restore();
     done();
   }, 100);
 });
開發者ID:cyclejs,項目名稱:cyclejs,代碼行數:16,代碼來源:dom-driver.ts

示例7: it

  it('should start emitting the current location', function(done) {
    const history$ = makeServerHistoryDriver()(xs.never());

    const sub = history$.subscribe({
      next: (location: Location) => {
        assert(location.pathname);
        done();
      },
      error: err => {},
      complete: () => {},
    });

    setTimeout(() => {
      sub.unsubscribe();
    });
  });
開發者ID:joeldentici,項目名稱:cyclejs,代碼行數:16,代碼來源:common.ts

示例8: child

    function child(sources: any, num: number) {
      const vdom$ = sources.HTTP
        // .select('cat')
        // .flatten()
        .map((res: any) => res.body.name)
        .map((name: string) => 'My name is ' + name);

      const request$ =
        num === 1
          ? xs.of({
              category: 'cat',
              url: 'http://jsonplaceholder.typicode.com/users/1',
            })
          : xs.never();

      return {
        HTTP: request$,
        DOM: vdom$,
      };
    }
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:20,代碼來源:run.ts

示例9: mainWithState

 return function mainWithState(sources: Forbid<So, N>): Omit<Si, N> {
   const reducerMimic$ = xs.create<Reducer<T>>();
   const state$ = reducerMimic$
     .fold((state, reducer) => reducer(state), void 0 as T | undefined)
     .drop(1);
   const innerSources: So = sources as any;
   innerSources[name] = new StateSource<any>(state$, name);
   const sinks = main(innerSources);
   if (sinks[name]) {
     const stream$ = concat(
       xs.fromObservable<Reducer<T>>(sinks[name]),
       xs.never()
     );
     stream$.subscribe({
       next: i => schedule(() => reducerMimic$._n(i)),
       error: err => schedule(() => reducerMimic$._e(err)),
       complete: () => schedule(() => reducerMimic$._c()),
     });
   }
   return sinks as any;
 };
開發者ID:,項目名稱:,代碼行數:21,代碼來源:


注:本文中的xstream.never函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。