• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript xstream.never函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript xstream.of函数代码示例发布时间:2022-05-25
下一篇:
TypeScript xstream.merge函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap