I dont get rxjs 6 with angular 6 with interval, switchMap, and map

前端 未结 2 1402
失恋的感觉
失恋的感觉 2020-12-30 01:03

I want to update my rxjs code to 6 got I don\'t get it.

Before I had the below that wouth poll for new data every 5 seconds:

import { Observable, int         


        
2条回答
  •  盖世英雄少女心
    2020-12-30 01:20

    The code should be something like the following. You need to use the pipe operator.

    import { interval } from 'rxjs';
    import { switchMap, map } from 'rxjs/operators';
    
    const result = interval(5000).pipe(
    switchMap(() => this._authHttp.get(url)),    
    map(res => res.results)
    )
    

提交回复
热议问题