To

See also

  • Official ReactiveX documentation: To
classmethod Observable.to_async(func, scheduler=None)

Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.

Example:

res = Observable.to_async(lambda x, y: x + y)(4, 3)
res = Observable.to_async(lambda x, y: x + y, Scheduler.timeout)(4, 3)
res = Observable.to_async(lambda x: log.debug(x),
                                    Scheduler.timeout)('hello')
Parameters:func (types.FunctionType) – Function to convert to an asynchronous function.
Keyword Arguments:
 scheduler (Scheduler) – Scheduler to run the function on. If not specified, defaults to rx.Scheduler.timeout().
Returns:Asynchronous function.
Return type:(types.FunctionType)
../../_images/toAsync.png
Observable.to_blocking()
Observable.to_dict(key_selector, element_selector=None)

Converts the observable sequence to a dict if it exists.

Parameters:key_selector (types.FunctionType) – A function which produces the key for the dict.
Keyword Arguments:
 element_selector (types.FunctionType) – An optional function which produces the element for the dict. If not present, defaults to the value from the observable sequence.
Returns:
An observable sequence with a single value of a dict
containing the values from the observable sequence.
Return type:(Observable)
Observable.to_future(future_ctor=None)

Converts an existing observable sequence to a Future

Example: future = rx.Observable.return_value(42).to_future(trollius.Future);

With config: rx.config[“Future”] = trollius.Future future = rx.Observable.return_value(42).to_future()

future_ctor – {Function} [Optional] The constructor of the future.
If not provided, it looks for it in rx.config.Future.

Returns {Future} An future with the last value from the observable sequence.

Observable.to_iterable()

Creates a list from an observable sequence.

Returns an observable sequence containing a single element with a list containing all the elements of the source sequence.

Observable.to_list()

Creates a list from an observable sequence.

Returns an observable sequence containing a single element with a list containing all the elements of the source sequence.

../../_images/toList.png
Observable.to_set()

Converts the observable sequence to a set.

Returns {Observable} An observable sequence with a single value of a set containing the values from the observable sequence.