当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript delay.default函数代码示例

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