October 2018
Intermediate to advanced
420 pages
10h 26m
English
The from_future operator converts a future object to an observable that emits zero, or one item. The marble diagram of this operator is shown in the following figure:

Its prototype is as follows:
Observable.from_future(future)
This operator converts future to an observable that emits the result of future if it succeeds, or the error raised by future if it does not. The following is an example of its usage:
import asynciofrom rx import Observableasync def foo(future): await asyncio.sleep(1) future.set_result(2)loop = asyncio.get_event_loop()done = loop.create_future()asyncio.ensure_future(foo(done)) ...