Create

See also

  • Official ReactiveX documentation: Create
classmethod Observable.create(subscribe)
../../_images/create.png
classmethod Observable.generate(initial_state, condition, iterate, result_selector, scheduler=None)

Generates an observable sequence by running a state-driven loop producing the sequence’s elements, using the specified scheduler to send out observer messages.

1 - res = rx.Observable.generate(0,
lambda x: x < 10, lambda x: x + 1, lambda x: x)
2 - res = rx.Observable.generate(0,
lambda x: x < 10, lambda x: x + 1, lambda x: x, Rx.Scheduler.timeout)

Keyword arguments: initial_state – Initial state. condition – Condition to terminate generation (upon returning False). iterate – Iteration step function. result_selector – Selector function for results produced in the

sequence.
scheduler – [Optional] Scheduler on which to run the generator loop.
If not provided, defaults to CurrentThreadScheduler.

Returns the generated sequence.

../../_images/generate.png
classmethod Observable.generate_with_relative_time(initial_state, condition, iterate, result_selector, time_selector, scheduler=None)

Generates an observable sequence by iterating a state from an initial state until the condition fails.

res = source.generate_with_relative_time(0,
lambda x: True, lambda x: x + 1, lambda x: x, lambda x: 500)

initial_state – Initial state. condition – Condition to terminate generation (upon returning false). iterate – Iteration step function. result_selector – Selector function for results produced in the

sequence.
time_selector – Time selector function to control the speed of values
being produced each iteration, returning integer values denoting milliseconds.
scheduler – [Optional] Scheduler on which to run the generator loop.
If not specified, the timeout scheduler is used.

Returns the generated sequence.

../../_images/generateWithRelativeTime.png