Questions tagged [rxjs-observables]

759 questions
3
votes
3 answers

RxJS: execute concatMap i parallel

Is it possible to execute a high-order observable in parallel, but still preserve the order when merging the results? I have something looking like this: invoker$: Observable; fetch: (index: number) => Observable; invoker$ .pipe( …
Mikkel R. Lund
  • 2,336
  • 1
  • 31
  • 44
3
votes
5 answers

How to repeat a promise conditionally using rxjs

I would like to repeat an API call which returns a Promise, conditionally using rxjs. The API method receives an id which will be changed on every call by adding a counter prefix to it. The calls will be repeated until the data met some condition or…
Asi
  • 43
  • 5
3
votes
1 answer

Angular RxJS: Do I need to do .takeUntil(this.destroy$) if I'm using async pipe?

If I have an element in my template which is using property binding, bound to an observable, using async pipe to ensure it is unsubscribed automatically...then would using takeUntil(this.destroy$) be unnecessary? Template snippet:
JTech
  • 3,420
  • 7
  • 44
  • 51
3
votes
2 answers

Angular, observable pipe limit?

I'm doing this in one of my route guards... canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { // go through each check sequentially, stop process if one does throwError return of(true).pipe( // Is…
milesmeow
  • 3,688
  • 5
  • 35
  • 58
3
votes
2 answers

What is the best way to patch fetched objects in RxJS?

I have a code that fetches book by its id const fetchBook = (bookId: number) => { const title = 'Book' + bookId; // mimic http request return timer(200).pipe(mapTo({ bookId, title })); } const bookId$ = new Subject(); const…
Artem
  • 1,773
  • 12
  • 30
3
votes
1 answer

How to prevent multiple fetch calling in RxJS?

I have the following code: const fetchBook = (bookId: number) => { const title = 'Book' + bookId; console.log('fetch book:', title) // mimic http request return timer(200).pipe(mapTo({ bookId, title })); } const bookId$ = new…
Artem
  • 1,773
  • 12
  • 30
3
votes
2 answers

rxjs - Angular: How to wait for an Observable function, to call another function that returns an Observable?

I have 2 API calls in a service that each return an Observable, and in my component I have some condition that, if true, I must call both those functions, but I need to wait for the get() call, so that I can execute the post function with arguments…
3
votes
1 answer

Angular api call: Observable vs Promise

I have this service that calls to an API to get a bunch of movie descriptions and returns an Observable: getNowPlayingMovies$(page: number, country?: string): Observable { …
jcobo1
  • 1,065
  • 1
  • 18
  • 34
3
votes
2 answers

How can I return an observable with a value that's in a callback?

I am writing a service that I intend will store local copies of Place objects and fetch them from a back end only when they are not stored locally. However, I am having trouble implementing this functionality. I could set up my page to call…
Matt McCarthy
  • 424
  • 6
  • 19
3
votes
2 answers

RxJS Observable forkJoin Not Executing in Parallel

I have the following code and, for the life of me, can't figure out why the requests don't execute concurrently. I'm still new to RxJS and observables, so any help in improving the code below would be greatly appreciated as well. Basically, I'm…
3
votes
2 answers

How can I correctly use RxJS to add a new field to each object of an array returned into an Observable?

I am not so into RxJS and I ahve the following doubt. Into this an Angular service class I have this method retrieving data from Firebase FireStore database: async getAllEmployees() { return >…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
3
votes
1 answer

RxJS "unsubsribe" method in ngOnDestroy does not disposes resources quickly enough

I am investigating an issue which appears to be coming from the fact that the "unsubscribe" method of the "Subscription" class does not appear to be disposing of the resources quickly enough which creates a memory leak. Here is my scenario: I have…
Georgi Koemdzhiev
  • 11,421
  • 18
  • 62
  • 126
3
votes
2 answers

Difference between using a variable and using a subject in angular service to create the global variable which can be used throughout the application?

Angular 8 provides us rxjs library , we can use subject from that library to set data that can be used gloabally in our application by declaring it in service file and this same we can do is by declaring just a variable in service file and using it…
prince
  • 31
  • 4
3
votes
1 answer

Update Rxjs observable of array by adding ,filtering or deleting items

I have some cards displayed in the UI.
...
Obviosuly cards will be the Observable of array of type card. So I have an interface of card lets say it has 3 properties Id, name, description. My use case…
3
votes
1 answer

How to continue catchError in timer (rxjs)

I have a service that is responsible to execute a httpClient.get every x seconds, using a timer. I need this timer to start running whenever the service is up, so the timer is defined in the service constructor. According to my understanding, the…
Guy E
  • 1,775
  • 2
  • 27
  • 55
1 2
3
50 51