123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- "use strict";
- var __extends = (this && this.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- var Observable_1 = require('../Observable');
- var RangeObservable = (function (_super) {
- __extends(RangeObservable, _super);
- function RangeObservable(start, count, scheduler) {
- _super.call(this);
- this.start = start;
- this._count = count;
- this.scheduler = scheduler;
- }
-
- RangeObservable.create = function (start, count, scheduler) {
- if (start === void 0) { start = 0; }
- if (count === void 0) { count = 0; }
- return new RangeObservable(start, count, scheduler);
- };
- RangeObservable.dispatch = function (state) {
- var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
- if (index >= count) {
- subscriber.complete();
- return;
- }
- subscriber.next(start);
- if (subscriber.closed) {
- return;
- }
- state.index = index + 1;
- state.start = start + 1;
- this.schedule(state);
- };
- RangeObservable.prototype._subscribe = function (subscriber) {
- var index = 0;
- var start = this.start;
- var count = this._count;
- var scheduler = this.scheduler;
- if (scheduler) {
- return scheduler.schedule(RangeObservable.dispatch, 0, {
- index: index, count: count, start: start, subscriber: subscriber
- });
- }
- else {
- do {
- if (index++ >= count) {
- subscriber.complete();
- break;
- }
- subscriber.next(start++);
- if (subscriber.closed) {
- break;
- }
- } while (true);
- }
- };
- return RangeObservable;
- }(Observable_1.Observable));
- exports.RangeObservable = RangeObservable;
|