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

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).
主站蜘蛛池模板: 镇远县| 尚志市| 久治县| 罗山县| 大宁县| 鲁山县| 永吉县| 隆化县| 钟山县| 罗源县| 延庆县| 张家港市| 芷江| 庄河市| 定日县| 阳泉市| 枞阳县| 山丹县| 噶尔县| 遵义县| 宜城市| 象州县| 察隅县| 遂宁市| 沂源县| 夏河县| 哈巴河县| 澄城县| 来凤县| 湖口县| 陇川县| 施秉县| 扎赉特旗| 中阳县| 吉首市| 宜州市| 和林格尔县| 额敏县| 临漳县| 阜南县| 买车|