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

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
主站蜘蛛池模板: 林州市| 翁源县| 通州区| 工布江达县| 台东市| 孝感市| 同江市| 连州市| 建水县| 辽阳市| 兴宁市| 康马县| 东港市| 封丘县| 上林县| 陇南市| 怀安县| 武穴市| 靖西县| 宁强县| 遵化市| 遂昌县| 临邑县| 汶川县| 金平| 敖汉旗| 衡山县| 安庆市| 奎屯市| 贺兰县| 正宁县| 琼海市| 抚松县| 甘谷县| 康定县| 金湖县| 奈曼旗| 仁怀市| 株洲县| 五寨县| 林芝县|