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

TypeScript delay.default函数代码示例

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

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



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

示例1: Child

    function Child(sources: {state: StateSource<ItemState>}) {
      const defaultReducer$ = xs.of((prev: ItemState) => {
        if (typeof prev.val === 'number') {
          return prev;
        } else {
          return {id: prev.id, val: 10};
        }
      });

      const deleteReducer$ = xs
        .of((prev: ItemState) => (prev.id === 'c' ? void 0 : prev))
        .compose(delay(50));

      return {
        state: xs.merge(defaultReducer$, deleteReducer$),
      };
    }
开发者ID:,项目名称:,代码行数:17,代码来源:


示例2: app

 function app(sources: {DOM: DOMSource}) {
   return {
     DOM: concat(
       xs.of(h2('.blesh', 'Blesh')),
       xs.of(h3('.blish', 'Blish')).compose(delay(150)),
       xs.of(h4('.blosh', 'Blosh')).compose(delay(150)),
     ),
   };
 }
开发者ID:joeldentici,项目名称:cyclejs,代码行数:9,代码来源:events.ts


示例3: Main

    function Main(sources: {state: StateSource<any>}) {
      sources.state.stream.addListener({
        next(x) {
          assert.deepEqual(x.list, expected.shift());
        },
        error(e) {
          done(e.message);
        },
        complete() {
          done('complete should not be called');
        },
      });

      const childSinks = isolate(List, 'list')(sources);
      const childReducer$ = childSinks.state;

      const initReducer$ = xs.of(function initReducer(prevState: any): any {
        return {list: [{val: 3}]};
      });

      const addReducer$ = xs
        .of(function addSecond(prev: any) {
          return {list: prev.list.concat({val: null})};
        })
        .compose(delay(100));

      const parentReducer$ = xs.merge(initReducer$, addReducer$);
      const reducer$ = xs.merge(parentReducer$, childReducer$) as Stream<
        Reducer<any>
      >;

      return {
        state: reducer$,
      };
    }
开发者ID:,项目名称:,代码行数:35,代码来源:


示例4:

 const Dataflow = ({ circular$}: Sources & Circular): Sinks & Circular => {
   return {
     circular$: circular$.map(x => x * 2)
       .startWith(1)
       .compose(delay(10)),
     target$: circular$.map(x => x * 10)
   }
 }
开发者ID:whitecolor,项目名称:cycle-circular,代码行数:8,代码来源:xstream.ts


示例5: app

  it('should not simulate bubbling for non-bubbling events', done => {
    function app(_sources: {DOM: DOMSource}) {
      return {
        DOM: xs.of(
          div('.parent', [form('.form', [input('.field', {type: 'text'})])])
        ),
      };
    }

    const {sinks, sources, run} = setup(app, {
      DOM: makeDOMDriver(createRenderTarget()),
    });

    sources.DOM.select('.parent')
      .events('reset')
      .addListener({
        next: (ev: Event) => {
          done(new Error('Reset event should not bubble to parent'));
        },
      });

    sources.DOM.select('.form')
      .events('reset')
      .compose(delay(200))
      .addListener({
        next: (ev: Event) => {
          assert.strictEqual(ev.type, 'reset');
          const target = ev.target as HTMLElement;
          assert.strictEqual(target.tagName, 'FORM');
          assert.strictEqual(target.className, 'form');
          done();
        },
      });

    sources.DOM.select(':root')
      .element()
      .drop(1)
      .take(1)
      .addListener({
        next: (root: Element) => {
          const _form = root.querySelector('.form') as HTMLFormElement;
          setTimeout(() => _form.reset());
        },
      });
    run();
  });
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:46,代码来源:events.ts


示例6: main

 function main(sources: {DOM: MainDOMSource}) {
   const remove$ = componentRemove$.compose(delay(50)).fold((acc) => acc + 1, 0);
   const first = isolate(Component, 'first')(sources);
   const second = isolate(Component, 'second')(sources);
   const vdom$ = xs.combine(first.DOM, second.DOM, remove$)
     .map(([vdom1, vdom2, r]) => {
       if (r === 0) {
         return div([vdom1, vdom2]);
       } else if (r === 1) {
         return div([vdom2]);
       } else if (r === 2) {
         return div([]);
       } else {
         done('This case must not happen.');
       }
     });
   return { DOM: vdom$ };
 }
开发者ID:whitecolor,项目名称:cyclejs,代码行数:18,代码来源:isolation.ts


示例7: app

 function app(sources: {DOM: MainDOMSource}) {
   const vtree1$ = xs.of(span('.tab1', 'Hi'));
   const vtree2$ = xs.of(span('.tab2', 'Hello'));
   const first$ = sources.DOM.isolateSink(vtree1$, '1');
   const second$ = sources.DOM.isolateSink(vtree2$, '2');
   const switched$ = concat(
     xs.of(1).compose(delay(50)),
     xs.of(2).compose(delay(50)),
     xs.of(1).compose(delay(50)),
     xs.of(2).compose(delay(50)),
     xs.of(1).compose(delay(50)),
     xs.of(2).compose(delay(50)),
   ).map(i => i === 1 ? first$ : second$).flatten();
   return {
     DOM: switched$,
   };
 }
开发者ID:whitecolor,项目名称:cyclejs,代码行数:17,代码来源:isolation.ts


示例8: driver

 function driver(sink: Stream<string>) {
   return sink.map(x => x.charCodeAt(0)).compose(delay(1));
 }
开发者ID:joeldentici,项目名称:cyclejs,代码行数:3,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript dropRepeats.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript debounce.default函数代码示例发布时间: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