October 2018
Intermediate to advanced
420 pages
10h 26m
English
Last but not least, AsyncIOScheduler allows us to schedule the emissions of an observable on an AsyncIO event loop. Obviously, when writing an application based on AsyncIO and ReactiveX, this is the most used scheduler. The prototype of this scheduler is the following one:
AsyncIOScheduler.__init__(self, loop=None)
The optional loop parameter allows us to specify the event loop to use with the scheduler. The default value uses the current event loop. Using this scheduler is the same as the other ones:
import asyncioimport threadingloop = asyncio.get_event_loop()asyncio_scheduler = AsyncIOScheduler()numbers = Observable.from_([1,2,3,4], scheduler=asyncio_scheduler)subscription = numbers \ .map(lambda i: i*2) \ .map(lambda ...