Refresh Rxjs

PHOTO EMBED

Fri Dec 23 2022 16:36:37 GMT+0000 (Coordinated Universal Time)

Saved by @ilivanilton #angular #rxjs-pattern

//html
<div *ngIf="let notice of (news$ | async)"> ...

//compoent
refreshTImer$ = timer(0, 30000)
news$ = this.service.news$
/*ngOnInit*/
this.sub = this.refreshTimer$.subscribe(this.service.refresh$)
/*ngOnDestroy*/
this.sub.unsubscribe()

//service
loadNews$ = this.http.get('/newsfeed')...
refresh$ = new BeharviorSubject(null);
news$ = this.refresh$.pipe(
 exhaustMap( () => this.loadNews$)
)
content_copyCOPY

https://youtu.be/B-nFj2o03i8?t=821