1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /** PURE_IMPORTS_START tslib,_innerSubscribe PURE_IMPORTS_END */
- import * as tslib_1 from "tslib";
- import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
- export function sample(notifier) {
- return function (source) { return source.lift(new SampleOperator(notifier)); };
- }
- var SampleOperator = /*@__PURE__*/ (function () {
- function SampleOperator(notifier) {
- this.notifier = notifier;
- }
- SampleOperator.prototype.call = function (subscriber, source) {
- var sampleSubscriber = new SampleSubscriber(subscriber);
- var subscription = source.subscribe(sampleSubscriber);
- subscription.add(innerSubscribe(this.notifier, new SimpleInnerSubscriber(sampleSubscriber)));
- return subscription;
- };
- return SampleOperator;
- }());
- var SampleSubscriber = /*@__PURE__*/ (function (_super) {
- tslib_1.__extends(SampleSubscriber, _super);
- function SampleSubscriber() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.hasValue = false;
- return _this;
- }
- SampleSubscriber.prototype._next = function (value) {
- this.value = value;
- this.hasValue = true;
- };
- SampleSubscriber.prototype.notifyNext = function () {
- this.emitValue();
- };
- SampleSubscriber.prototype.notifyComplete = function () {
- this.emitValue();
- };
- SampleSubscriber.prototype.emitValue = function () {
- if (this.hasValue) {
- this.hasValue = false;
- this.destination.next(this.value);
- }
- };
- return SampleSubscriber;
- }(SimpleOuterSubscriber));
- //# sourceMappingURL=sample.js.map
|