You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
4.8 KiB
1 line
4.8 KiB
2 years ago
|
{"version":3,"file":"sampleTime.js","sourceRoot":"","sources":["../../src/operators/sampleTime.ts"],"names":[],"mappings":";;;;;;AAEA,2BAA2B,eAAe,CAAC,CAAA;AAG3C,sBAAsB,oBAAoB,CAAC,CAAA;AAK3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,oBAA8B,MAAc,EAAE,SAA6B;IAA7B,yBAA6B,GAA7B,yBAA6B;IACzE,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAAtD,CAAsD,CAAC;AAC3F,CAAC;AAFe,kBAAU,aAEzB,CAAA;AAED;IACE,4BAAoB,MAAc,EACd,SAAqB;QADrB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;IACzC,CAAC;IAED,iCAAI,GAAJ,UAAK,UAAyB,EAAE,MAAW;QACzC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,oBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7F,CAAC;IACH,yBAAC;AAAD,CAAC,AARD,IAQC;AAED;;;;GAIG;AACH;IAAsC,wCAAa;IAIjD,8BAAY,WAA0B,EAClB,MAAc,EACd,SAAqB;QACvC,kBAAM,WAAW,CAAC,CAAC;QAFD,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QAJzC,aAAQ,GAAY,KAAK,CAAC;QAMxB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,cAAM,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IAES,oCAAK,GAAf,UAAgB,KAAQ;QACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,yCAAU,GAAV;QACE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACH,2BAAC;AAAD,CAAC,AAtBD,CAAsC,uBAAU,GAsB/C;AAED,8BAAoD,KAAU;IACtD,iCAAU,EAAE,qBAAM,CAAW;IACnC,UAAU,CAAC,UAAU,EAAE,CAAC;IACxB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { Observable } from '../Observable';\nimport { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { IScheduler } from '../Scheduler';\nimport { Action } from '../scheduler/Action';\nimport { async } from '../scheduler/async';\nimport { TeardownLogic } from '../Subscription';\n\nimport { MonoTypeOperatorFunction } from '../interfaces';\n\n/**\n * Emits the most recently emitted value from the source Observable within\n * periodic time intervals.\n *\n * <span class=\"informal\">Samples the source Observable at periodic time\n * intervals, emitting what it samples.</span>\n *\n * <img src=\"./img/sampleTime.png\" width=\"100%\">\n *\n * `sampleTime` periodically looks at the source Observable and emits whichever\n * value it has most recently emitted since the previous sampling, unless the\n * source has not emitted anything since the previous sampling. The sampling\n * happens periodically in time every `period` milliseconds (or the time unit\n * defined by the optional `scheduler` argument). The sampling starts as soon as\n * the output Observable is subscribed.\n *\n * @example <caption>Every second, emit the most recent click at most once</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var result = clicks.sampleTime(1000);\n * result.subscribe(x => console.log(x));\n *\n * @see {@link auditTime}\n * @see {@link debounceTime}\n * @see {@link delay}\n * @see {@link sample}\n * @see {@link throttleTime}\n *\n * @param {number} period The sampling period expressed in milliseconds or the\n * time unit determined internally by the optional `scheduler`.\n * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for\n * managing the timers that handle the sampling.\n * @return {Observable<T>} An Observable that emits the results of sampling the\n * values emitted by the source Observable at the specified time interval.\n * @method sampleTime\n * @owner Observable\n */\nexport function sampleTime<T>(period: number, scheduler: IScheduler = async): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>) => source.lift(new SampleTimeOperator(period, scheduler));\n}\n\nclass SampleTimeOperator<T> implements Operator<T, T> {\n constructor(private period: number,\n private scheduler: IScheduler) {\n }\n\n call(subscriber: Subscriber<T>, source: any): TeardownLogic {\n return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\
|