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


TypeScript xstream.periodic函数代码示例

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


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

示例1: test

test('xstream: proxy$ should stop emitting when proxied$ unsubscribed', (t) => {
  let target$ = xs.periodic(0)
  let proxy$ = proxy()

  let proxied$ = proxy$.proxy(target$)
  let emitted = 0
  proxy$.addListener({
    next: () => {
      emitted++
    },
    error: () => { },
    complete: () => { }
  })

  let listener = {
    next: () => {
      if (emitted === 2) {
        proxied$.removeListener(listener)
      }
    },
    error: () => { },
    complete: () => { }
  }
  proxied$.addListener(listener)

  // target may still be subscribed
  target$.addListener(emptyListener)

  setTimeout(() => {
    t.equal(emitted, 3)
    t.end()
  }, 50)
})
开发者ID:whitecolor,项目名称:cycle-circular,代码行数:33,代码来源:xstream.ts

示例2: child

 function child(sources: {DOM: MainDOMSource}) {
   const visible$ = xs.periodic(50).take(1).fold((acc, _) => !acc, true);
   const vdom$ = visible$.map(visible => (visible ? h4('child') : null));
   return {
     DOM: vdom$,
   };
 }
开发者ID:joeldentici,项目名称:cyclejs,代码行数:7,代码来源:isolation.ts

示例3: app

 function app() {
   return {
     html: xs
       .periodic(150)
       .take(3)
       .map(i => div('.test-element', ['Foobar' + i])),
   };
 }
开发者ID:joeldentici,项目名称:cyclejs,代码行数:8,代码来源:index.ts

示例4: main

 function main(sources: {DOM: MainDOMSource}) {
   const child = isolate(Child, 'child')(sources);
   // change parent key, causing it to be recreated
   const x$ = xs.periodic(120).map(x => x + 1).startWith(0).take(4);
   const innerDOM$ = xs.combine(x$, child.DOM)
     .map(([x, childVDOM]) =>
       div(`.parent${x}`, {key: `key${x}`}, [childVDOM, `${x}`]),
     );
   return {
     DOM: innerDOM$,
   };
 }
开发者ID:whitecolor,项目名称:cyclejs,代码行数:12,代码来源:isolation.ts

示例5: main

 function main(sources: {history: Stream<Location>}) {
   return {
     history: xs.periodic(100).take(6).map(i => [
       '/test',
       '/other',
       {type: 'go', amount: -1},
       {type: 'go', amount: +1},
       {type: 'goBack'},
       {type: 'goForward'},
     ][i]),
   };
 }
开发者ID:whitecolor,项目名称:cyclejs,代码行数:12,代码来源:xstream.ts

示例6: mainDOMThenHTTP

    function mainDOMThenHTTP(sources: any) {
      const sinks$ = xs
        .periodic(100)
        .take(6)
        .map(i => {
          if (i % 2 === 1) {
            return child(sources, i);
          } else {
            return {
              HTTP: xs.empty(),
              DOM: xs.of(''),
            };
          }
        });

      // order of sinks is important to reproduce the bug
      return {
        DOM: sinks$.map(sinks => sinks.DOM).flatten(),
        HTTP: sinks$.map(sinks => sinks.HTTP).flatten(),
      };
    }
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:21,代码来源:run.ts

示例7: app

 function app(sources: MySources) {
   return {other: xs.periodic(100).map(i => i + 1)};
 }
开发者ID:joeldentici,项目名称:cyclejs,代码行数:3,代码来源:index.ts

示例8: main

function main() {
	const sinks = {
		DOM: xs.periodic(1000).map(i => h1('' + i + " seconds elapsed"))
	};
  return sinks;
}
开发者ID:udondokodoon,项目名称:touchevents,代码行数:6,代码来源:main.ts


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