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

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
主站蜘蛛池模板: 黎平县| 溆浦县| 乡城县| 荔浦县| 娄烦县| 三台县| 汾阳市| 永寿县| 清水河县| 柯坪县| 吉水县| 治县。| 沙湾县| 昌图县| 南陵县| 华容县| 北流市| 佛山市| 达州市| 呼和浩特市| 陆良县| 游戏| 江山市| 尉氏县| 郑州市| 佳木斯市| 枣庄市| 临泉县| 山阴县| 通道| 达孜县| 邵东县| 灵石县| 吴堡县| 中西区| 隆安县| 黄骅市| 新龙县| 高淳县| 安乡县| 关岭|