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.
101 lines
3.5 KiB
101 lines
3.5 KiB
/** PURE_IMPORTS_START .._Observable PURE_IMPORTS_END */ |
|
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 __()); |
|
}; |
|
import { Observable } from '../Observable'; |
|
/** |
|
* We need this JSDoc comment for affecting ESDoc. |
|
* @extends {Ignored} |
|
* @hide true |
|
*/ |
|
export var RangeObservable = /*@__PURE__*/ (/*@__PURE__*/ function (_super) { |
|
__extends(RangeObservable, _super); |
|
function RangeObservable(start, count, scheduler) { |
|
_super.call(this); |
|
this.start = start; |
|
this._count = count; |
|
this.scheduler = scheduler; |
|
} |
|
/** |
|
* Creates an Observable that emits a sequence of numbers within a specified |
|
* range. |
|
* |
|
* <span class="informal">Emits a sequence of numbers in a range.</span> |
|
* |
|
* <img src="./img/range.png" width="100%"> |
|
* |
|
* `range` operator emits a range of sequential integers, in order, where you |
|
* select the `start` of the range and its `length`. By default, uses no |
|
* IScheduler and just delivers the notifications synchronously, but may use |
|
* an optional IScheduler to regulate those deliveries. |
|
* |
|
* @example <caption>Emits the numbers 1 to 10</caption> |
|
* var numbers = Rx.Observable.range(1, 10); |
|
* numbers.subscribe(x => console.log(x)); |
|
* |
|
* @see {@link timer} |
|
* @see {@link interval} |
|
* |
|
* @param {number} [start=0] The value of the first integer in the sequence. |
|
* @param {number} [count=0] The number of sequential integers to generate. |
|
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling |
|
* the emissions of the notifications. |
|
* @return {Observable} An Observable of numbers that emits a finite range of |
|
* sequential integers. |
|
* @static true |
|
* @name range |
|
* @owner Observable |
|
*/ |
|
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); |
|
}; |
|
/** @deprecated internal use only */ 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)); |
|
//# sourceMappingURL=RangeObservable.js.map
|
|
|