Example #1
0
    def start(cls, func, scheduler=None):
        """Invokes the specified function asynchronously on the specified
        scheduler, surfacing the result through an observable sequence.

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

        Keyword arguments:
        func -- {Function} Function to run asynchronously.
        scheduler -- {Scheduler} [Optional] Scheduler to run the function on. If
            not specified, defaults to Scheduler.timeout.

        Returns {Observable} An observable sequence exposing the function's
        result value, or an exception.

        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."""

        return Observable.to_async(func, scheduler)()
Example #2
0
        def create():
            def func(a, b, c, d):
                return a + b + c + d

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

            return Observable.to_async(func, scheduler)(1, 2, 3)
Example #4
0
        def create():
            def func(x):
                return x

            return Observable.to_async(func, scheduler)(1)
Example #5
0
 def create():
     context = Context()
     return Observable.to_async(context.func, scheduler)(42)
Example #6
0
        def create():
            def func(a, b, c):
                raise ex

            return Observable.to_async(func, scheduler)(1, 2, 3)