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

Observables from promises (fromPromise)

You can also create EventStreams from ES6 promises or jQuery AJAX. These streams will contain only a single value (or an error in case of failure), and finish. We will need a promise to test this method:

var promiseObject = Promise.resolve(10); 

Here, we are creating a successful promise that will return the value 10. To transform this promise into an EventStream, we use the following code:

Bacon 
.fromPromise(promiseObject);
Keep in mind you will need Node.js version 4 or above, or a modern browser to test this code (old browsers don't have promises implemented).
主站蜘蛛池模板: 邢台县| 九龙县| 汝南县| 汪清县| 肥乡县| 子长县| 漳州市| 孝义市| 章丘市| 凌云县| 鹰潭市| 峨眉山市| 潜山县| 托克逊县| 茂名市| 都江堰市| 罗城| 富裕县| 白山市| 连州市| 贵阳市| 射洪县| 罗甸县| 察哈| 桃园市| 鸡泽县| 渭南市| 合水县| 淅川县| 浠水县| 芜湖市| 定州市| 沾益县| 武清区| 改则县| 利津县| 富阳市| 科技| 青川县| 浑源县| 临高县|