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

  • Mastering Reactive JavaScript
  • Erich de Souza Oliveira
  • 114字
  • 2021-07-09 20:33:07

Observables from an interval (interval)

We can create an observable from an interval; this is especially useful if you wish to execute repetitive tasks, and it can be used as a substitution for the setInterval() method. An EventStream created by the interval() method will never end; this method has the following signature:

Bacon.interval(intervalInMilliseconds); 

It receives only one parameter, that is the interval between the events in milliseconds, and it will emit an empty object as the event. Let's say you have run the following code:

Bacon 
.interval(100)
.onValue((event)=>{
console.log(event);
});

If so, you will see the following output:

    {}
{}
{}
{}

It will keep printing an empty object until you kill the program.

主站蜘蛛池模板: 丽江市| 皋兰县| 牡丹江市| 元朗区| 迁安市| 五大连池市| 大足县| 麻江县| 资中县| 宣恩县| 鄂托克前旗| 简阳市| 肥城市| 佳木斯市| 巫溪县| 右玉县| 黑龙江省| 嘉荫县| 安平县| 曲麻莱县| 鲜城| 黔东| 五寨县| 寿宁县| 航空| 凤阳县| 项城市| 黎城县| 青阳县| 利津县| 青浦区| 铜川市| 渝中区| 横峰县| 合肥市| 杭州市| 永仁县| 兴安盟| 安乡县| 米林县| 东阳市|