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

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).
主站蜘蛛池模板: 新昌县| 沁源县| 阿拉善右旗| 稷山县| 澄城县| 新昌县| 南丹县| 神池县| 盐城市| 慈利县| 扶沟县| 永胜县| 平顺县| 通河县| 宁晋县| 鹤岗市| 高邑县| 大同县| 静宁县| 镇巴县| 凭祥市| 漳平市| 汾西县| 出国| 涞水县| 台中县| 榆林市| 龙海市| 阳原县| 买车| 甘洛县| 瑞安市| 庆阳市| 深圳市| 左权县| 工布江达县| 彭泽县| 确山县| 青铜峡市| 中山市| 浑源县|