当前位置: 首页>>代码示例>>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;未经允许,请勿转载。