The just operator

The just operator returns an observable that emits only one item, and then it completes immediately. The marble diagram of this operator is shown in the following figure:

Figure 4.2: The just operator

Its prototype is as follows:

Observable.just(value, scheduler=None)

The following is an example of how to use it:

number = Observable.just(1)
number.subscribe(
on_next=lambda i: print("item: {}".format(i)),
on_error=lambda e: print("error: {}".format(e)),
on_completed=lambda: print("completed")
)

Upon subscription, the number 1, provided in the just operator, is emitted as the only item of the observable before the observable completes:

item: 1
completed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.98.208