当前位置: 首页>>代码示例>>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;未经允许,请勿转载。