當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。