Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created October 12, 2020 07:31
Show Gist options
  • Save LironHazan/cee022a46fc9e15aea278421acf32a29 to your computer and use it in GitHub Desktop.
Save LironHazan/cee022a46fc9e15aea278421acf32a29 to your computer and use it in GitHub Desktop.
Assaf Azulai's example for rxjs post
interactionSubject = new Subject<void>();
ngOnInit() {
this.interactionSubject.asObservable().pipe(
switchMap((data) => {
this.server.fetchData(data).pipe(
catchError((err) => {
// handle error
})
)
})
).subscribe(dataFromServer => {
// Do something
});
}
interaction1() {
this.interactionSubject.next();
}
interaction2() {
this.interactionSubject.next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment