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

  • 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.

主站蜘蛛池模板: 阳城县| 嘉禾县| 张北县| 温宿县| 呈贡县| 大关县| 离岛区| 南木林县| 余庆县| 泾源县| 乌鲁木齐市| 中牟县| 崇明县| 屏东县| 恩平市| 桃园市| 正镶白旗| 新田县| 永宁县| 双辽市| 湟中县| 淮安市| 凌海市| 合阳县| 米脂县| 山丹县| 凤凰县| 法库县| 平顶山市| 图片| 卢湾区| 蕲春县| 康保县| 贡山| 河北区| 登封市| 高碑店市| 包头市| 哈巴河县| 隆子县| 岫岩|