generate
Parameters
Returns
Observable<T>
Overloads
const generated = generate(0, x => x < 3, x => x + 1);generated.subscribe( value => console.log(value), err => {}, () => console.log('Yo!') );
// Logs: // 0 // 1 // 2 // "Yo!"
@example
const generated = generate(0, x => x < 3, x => x + 1, x => x * 1000);generated.subscribe( value => console.log(value), err => {}, () => console.log('Yo!') );
// Logs: // 0 // 1000 // 2000 // "Yo!"
@example
const generated = generate({ initialState: 0, condition(value) { return value < 3; }, iterate(value) { return value + 1; }, resultSelector(value) { return value * 1000; } });generated.subscribe( value => console.log(value), err => {}, () => console.log('Yo!') );
// Logs: // 0 // 1000 // 2000 // "Yo!"
@example
const generated = generate({ initialState: 0, iterate(value) { return value + 1; }, resultSelector(value) { return value * 1000; } });generated.subscribe( value => console.log(value), err => {}, () => console.log('Yo!') // This will never run. );
// Logs: // 0 // 1000 // 2000 // 3000 // ...and never stops.
@param {S} initialState Initial state.
@param {function (state: S): boolean} condition Condition to terminate generation (upon returning false).
@param {function (state: S): S} iterate Iteration step function.
@param {function (state: S): T} [resultSelector] Selector function for results produced in the sequence.
@param {Scheduler} [scheduler] A Scheduler
on which to run the generator loop. If not provided, defaults to emitting immediately.
@return {Observable
Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. Parameters
Returns
|
||||||||||
Generates an Observable by running a state-driven loop that emits an element on each iteration. Parameters
Returns
Use it instead of nexting values in a for loop.
Return value of a Optionally you can pass fourth parameter to If you find three anonymous functions in Both forms of @example | ||||||||||
Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. The overload accepts options object that might contain initial state, iterate, condition and scheduler. Parameters
Returns
|
||||||||||
Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. The overload accepts options object that might contain initial state, iterate, condition, result selector and scheduler. Parameters
Returns
|