import { IScheduler } from '../Scheduler'; import { Observable } from '../Observable'; import { Subscriber } from '../Subscriber'; import { Subscription } from '../Subscription'; export declare type ConditionFunc = (state: S) => boolean; export declare type IterateFunc = (state: S) => S; export declare type ResultFunc = (state: S) => T; export interface GenerateBaseOptions { /** * Initial state. */ initialState: S; /** * Condition function that accepts state and returns boolean. * When it returns false, the generator stops. * If not specified, a generator never stops. */ condition?: ConditionFunc; /** * Iterate function that accepts state and returns new state. */ iterate: IterateFunc; /** * IScheduler to use for generation process. * By default, a generator starts immediately. */ scheduler?: IScheduler; } export interface GenerateOptions extends GenerateBaseOptions { /** * Result selection function that accepts state and returns a value to emit. */ resultSelector: ResultFunc; } /** * We need this JSDoc comment for affecting ESDoc. * @extends {Ignored} * @hide true */ export declare class GenerateObservable extends Observable { private initialState; private condition; private iterate; private resultSelector; private scheduler; constructor(initialState: S, condition: ConditionFunc, iterate: IterateFunc, resultSelector: ResultFunc, scheduler?: IScheduler); /** * Generates an observable sequence by running a state-driven loop * producing the sequence's elements, using the specified scheduler * to send out observer messages. * * * * @example Produces sequence of 0, 1, 2, ... 9, then completes. * var res = Rx.Observable.generate(0, x => x < 10, x => x + 1, x => x); * * @example Using asap scheduler, produces sequence of 2, 3, 5, then completes. * var res = Rx.Observable.generate(1, x => x < 5, x => x * 2, x => x + 1, Rx.Scheduler.asap); * * @see {@link from} * @see {@link create} * * @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 {@link IScheduler} on which to run the generator loop. If not provided, defaults to emit immediately. * @returns {Observable} The generated sequence. */ static create(initialState: S, condition: ConditionFunc, iterate: IterateFunc, resultSelector: ResultFunc, scheduler?: IScheduler): 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. * The overload uses state as an emitted value. * * * * @example Produces sequence of 0, 1, 2, ... 9, then completes. * var res = Rx.Observable.generate(0, x => x < 10, x => x + 1); * * @example Using asap scheduler, produces sequence of 1, 2, 4, then completes. * var res = Rx.Observable.generate(1, x => x < 5, x => x * 2, Rx.Scheduler.asap); * * @see {@link from} * @see {@link create} * * @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 {Scheduler} [scheduler] A {@link IScheduler} on which to run the generator loop. If not provided, defaults to emit immediately. * @returns {Observable} The generated sequence. */ static create(initialState: S, condition: ConditionFunc, iterate: IterateFunc, scheduler?: IScheduler): 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. * The overload accepts options object that might contain initial state, iterate, * condition and scheduler. * * * * @example Produces sequence of 0, 1, 2, ... 9, then completes. * var res = Rx.Observable.generate({ * initialState: 0, * condition: x => x < 10, * iterate: x => x + 1 * }); * * @see {@link from} * @see {@link create} * * @param {GenerateBaseOptions} options Object that must contain initialState, iterate and might contain condition and scheduler. * @returns {Observable} The generated sequence. */ static create(options: GenerateBaseOptions): 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. * The overload accepts options object that might contain initial state, iterate, * condition, result selector and scheduler. * * * * @example Produces sequence of 0, 1, 2, ... 9, then completes. * var res = Rx.Observable.generate({ * initialState: 0, * condition: x => x < 10, * iterate: x => x + 1, * resultSelector: x => x * }); * * @see {@link from} * @see {@link create} * * @param {GenerateOptions} options Object that must contain initialState, iterate, resultSelector and might contain condition and scheduler. * @returns {Observable} The generated sequence. */ static create(options: GenerateOptions): Observable; /** @deprecated internal use only */ _subscribe(subscriber: Subscriber): Subscription | Function | void; private static dispatch(state); }