Exemple #1
0
def start_(func: Callable[[], _T],
           scheduler: Optional[abc.SchedulerBase] = None) -> Observable[_T]:
    """Invokes the specified function asynchronously on the specified
    scheduler, surfacing the result through an observable sequence.

    Example:
        >>> res = reactivex.start(lambda: pprint('hello'))
        >>> res = reactivex.start(lambda: pprint('hello'), rx.Scheduler.timeout)

    Args:
        func: Function to run asynchronously.
        scheduler: [Optional] Scheduler to run the function on. If
            not specified, defaults to Scheduler.timeout.

    Remarks:
        The function is called immediately, not during the subscription
        of the resulting sequence. Multiple subscriptions to the
        resulting sequence can observe the function's result.

    Returns:
        An observable sequence exposing the function's result value,
        or an exception.
    """

    return to_async(func, scheduler)()
Exemple #2
0
        def create():
            def func(x, y, z):
                return x + y + z

            return reactivex.to_async(func, scheduler)(1, 2, 3)
Exemple #3
0
        def create():
            def func(a, b, c, d):
                return a + b + c + d

            return reactivex.to_async(func, scheduler)(1, 2, 3, 4)
Exemple #4
0
        def create():
            def func(x, y):
                return x + y

            return reactivex.to_async(func, scheduler)(1, 2)
Exemple #5
0
        def create():
            def func(x):
                return x

            return reactivex.to_async(func, scheduler)(1)
Exemple #6
0
 def create():
     context = Context()
     return reactivex.to_async(context.func, scheduler)(42)
Exemple #7
0
        def create():
            def func(a, b, c, d):
                raise ex

            return reactivex.to_async(func, scheduler)(1, 2, 3, 4)
Exemple #8
0
        def create():
            def func(a):
                raise ex

            return reactivex.to_async(func, scheduler)(1)