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

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
主站蜘蛛池模板: 石家庄市| 宣恩县| 景泰县| 铁力市| 体育| 连城县| 尼勒克县| 鹤岗市| 卓尼县| 德昌县| 郎溪县| 舒城县| 廊坊市| 东港市| 绥棱县| 山西省| 同仁县| 邳州市| 谷城县| 平乐县| 泉州市| 紫云| 如东县| 泰来县| 乌恰县| 雷山县| 海南省| 淳化县| 和田县| 洱源县| 栾川县| 古浪县| 永吉县| 文成县| 奇台县| 台北县| 磐安县| 惠州市| 兰考县| 汾西县| 都江堰市|