RXJS cancel-restart observable on new data - switchMap

PHOTO EMBED

Wed Jun 29 2022 17:11:49 GMT+0000 (Coordinated Universal Time)

Saved by @Polly

load and display initial data 
listen for user input and make request 
cancel the request if the user input changes 
restart request with new user input
display new data from request

// used in html display - ( initial and continuous listener ) 
initialAndSearch$ = (initial$, new$)

// restart the second obsMethod when input changes
search$ = from(input src).pipe().switchMap(input => response$)
response$ = from(http src)
initial$ = from(response$) 
content_copyCOPY

concat($1, $2) - display initial data plus data from new request ngAfterViewInit - get input from html during page use

https://angular-university.io/lesson/rxjs-switchmap-operator