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


TypeScript operators.sampleTime函數代碼示例

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


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

示例1: sampleObservable

export function sampleObservable(obs: Observable<any>, scheduler?: any) {
  return obs.pipe(
    sampleTime(100, scheduler),
    share(),
    startWith('')
  );
}
開發者ID:tjoskar,項目名稱:ng2-lazyload-image,代碼行數:7,代碼來源:scroll-listener.ts

示例2: it

  it('should completes if source does not emits', () => {
    const e1 =  cold('|');
    const e1subs =   '(^!)';
    const expected = '|';

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

示例3: asDiagram

  asDiagram('sampleTime(70)')('should get samples on a delay', () => {
    const e1 =   hot('a---b-c---------d--e---f-g-h--|');
    const e1subs =   '^                             !';
    const expected = '-------c-------------e------h-|';
    // timer          -------!------!------!------!--

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

示例4: _updateUpdateRateObservable

    private _updateUpdateRateObservable(item: IoSourceItems) {
        const [source, , updateRate, association, updateSubject, updateSubscription] = item;

        // Unsubscribe and discard already scheduled IO values
        updateSubscription && updateSubscription.unsubscribe();

        if (!association.value) {
            item[5] = undefined;
            return;
        }

        const rate = updateRate.value;
        let updateObs: Observable<any>;

        if (rate === undefined || rate === 0) {
            updateObs = updateSubject;
        } else {
            switch (source.updateStrategy || IoSourceBackpressureStrategy.Default) {
                case IoSourceBackpressureStrategy.Default:
                case IoSourceBackpressureStrategy.Sample:
                    updateObs = updateSubject.pipe(sampleTime(rate));
                    break;
                case IoSourceBackpressureStrategy.Throttle:
                    updateObs = updateSubject.pipe(debounceTime(rate));
                    break;
                case IoSourceBackpressureStrategy.None:
                    updateObs = updateSubject;
                    break;
                default:
                    updateObs = updateSubject;
                    break;
            }
        }

        item[5] = updateObs.subscribe(value =>
            this.communicationManager.publishIoValue(source, value));
    }
開發者ID:coatyio,項目名稱:coaty-js,代碼行數:37,代碼來源:io-source-controller.ts


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