當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.sample函數代碼示例

本文整理匯總了TypeScript中rxjs/operators.sample函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript sample函數的具體用法?TypeScript sample怎麽用?TypeScript sample使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sample函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: sample1

 sample1() {
   // emit value every 1s
   const source = interval(1000);
   // sample last emitted value from source every 2s
   const example = source.pipe(sample(interval(2000)));
   // output: 2..4..6..8..
   const subscribe = example.subscribe(val => console.log(val));
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:8,代碼來源:filtering.service.ts

示例2: sample3

 sample3() {
   const listener = merge(
     fromEvent(document, 'mousedown').pipe(mapTo(false)),
     fromEvent(document, 'mousemove').pipe(mapTo(true))
   )
     .pipe(sample(fromEvent(document, 'mouseup')))
     .subscribe(isDragging => {
       console.log('Were you dragging?', isDragging);
     });
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:10,代碼來源:filtering.service.ts

示例3: asDiagram

  asDiagram('sample')('should get samples when the notifier emits', () => {
    const e1 =   hot('---a----b---c----------d-----|   ');
    const e1subs =   '^                            !   ';
    const e2 =   hot('-----x----------x---x------x---|');
    const e2subs =   '^                            !   ';
    const expected = '-----a----------c----------d-|   ';

    expectObservable(e1.pipe(sample(e2))).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
    expectSubscriptions(e2.subscriptions).toBe(e2subs);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:11,代碼來源:sample-spec.ts

示例4: it

  it('should complete only when the source completes, if notifier completes early', () => {
    const e1 =   hot('----a----b----c----d----e----f---|');
    const e1subs =   '^                                !';
    const e2 =   hot('------x-|                         ');
    const e2subs =   '^       !                         ';
    const expected = '------a--------------------------|';

    expectObservable(e1.pipe(sample(e2))).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
    expectSubscriptions(e2.subscriptions).toBe(e2subs);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:11,代碼來源:sample-spec.ts


注:本文中的rxjs/operators.sample函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。