How to make an http call every 2 minutes with RXJS?

前端 未结 5 407
猫巷女王i
猫巷女王i 2020-12-03 05:14

I have a service that will make a call to my rest service every 2 minutes. On my service I have the following function

  getNotifications(token: string) {
           


        
5条回答
  •  伪装坚强ぢ
    2020-12-03 05:50

    If you are using rxJs 6+, you can simlpy use interval method to do. like this -

    import { interval } from 'rxjs';
    
    interval(3000).subscribe(x => /* do something */)
    

提交回复
热议问题