官术网_书友最值得收藏!

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
主站蜘蛛池模板: 阳山县| 徐州市| 岳西县| 金乡县| 石棉县| 洱源县| 峨眉山市| 景东| 和政县| 靖州| 阳春市| 东海县| 洞口县| 呼和浩特市| 中阳县| 舟曲县| 宁波市| 景泰县| 博白县| 于田县| 秭归县| 资阳市| 班玛县| 西丰县| 乳山市| 改则县| 镇宁| 长海县| 江阴市| 诏安县| 南召县| 确山县| 石渠县| 杨浦区| 获嘉县| 涟水县| 陇南市| SHOW| 康保县| 哈巴河县| 彰化县|