Questions tagged [rxjs-observables]

759 questions
1
vote
3 answers

How do you declare a GET call with parameters?

A technique of getting data from a an API is to declare it like this in the service: getItems$ = this.httpClient.get(this.url); then either subscribe to it or utilize async in the consuming component. How would you do this if the get call…
ScubaSteve
  • 7,724
  • 8
  • 52
  • 65
1
vote
1 answer

How to use switchMap in RxJs Subsciption array?

I want to use switchMap in my subscriptions array, I want to call invokeRequest method which triggers http requests, basically I want to cancel subscription if same http call is triggered, can anyone please help. private subscriptions:…
1
vote
3 answers

Behavior subjects (Rxjs) gets called automatically

I am using RxJs Behaviour subjects in following manner as below. => Made a common service for all behaviour subjects like sample code below @Injectable() export class ProjectJobSelectionService { public postTypeSubject = new…
kushal Baldev
  • 729
  • 1
  • 14
  • 37
1
vote
1 answer

Format Angular observable data for PrimeNG Table

I have a project based on the Angular.io tutorial, including "Hero"-interface and data, as well as a "HeroService" using HTTPClient. I am able to fetch the data and display it using standard HTML in the template, but not when using the PrimeNG…
1
vote
1 answer

spyOn Observable timer not possible - Argument of type 'string' is not assignable to parameter of type 'never'

I get the error Argument of type 'string' is not assignable to parameter of type 'never'. When trying to spy on timer like this: it('should start a timer', async () => { spyOn(Observable, 'timer'); }); Import statement: import { Observable }…
Silv
  • 673
  • 5
  • 19
1
vote
2 answers

Getting error making a API call(using mergeMap) from the result array of forkJoin and need the combinedResult in Angular

Currently I am making 3 different API calls which are below like this:- //API Call1 getUserById(id){ return this.http .get(`${environment.userAPI}/user/${Id}`, { headers: this.headers }) .pipe( catchError(err => { …
1
vote
2 answers

Use RxJs operator like merge but keep track of source observables in the result?

I want to combine observables as is done with the "merge" operator but I still want to be able to know which input observable emitted, is there a way to do that? For example: private result$ = merge(this.obs1$, this.obs2$).pipe( scan((result,…
user10103655
  • 111
  • 1
  • 11
1
vote
3 answers

Value from BehaviorSubject is not rendered in the subscribed component

I'm passing a value from a service to a component using BehaviorSubject - In serviceFile.service.ts: taskComplete = new BehaviorSubject<{ complete: Boolean; error: any }>(null); ... this.taskComplete.next({ complete: false, error: error }); ... In…
Mahmoud
  • 60
  • 8
1
vote
1 answer

Why does RxJs finalize execute before chained http calls are complete?

Angular 11 site. I've searched all over but I'm still struggling with what seems like it should be a pretty common scenario. Goal: Do an http call to retrieve a list of items, then do another http call to retrieve details for the first item. After…
Roobot
  • 860
  • 1
  • 10
  • 20
1
vote
2 answers

Observable value not updated on UI

I'm working on an Angular app and among other features, now I'm working on an image gallery (carousel). When the user opens the image gallery, he's also able to upload new photos. Because I need to know the upload process globally, I'm trying to…
Sergiu Molnar
  • 865
  • 1
  • 11
  • 22
1
vote
2 answers

RxJS group by field and return new observable

I've following interfaces and Observable, what I want to achive is group by Machine symbol property in Observable and return mapped observable Observable. export interface Machine { symbol: string; price:…
Mateusz S.
  • 21
  • 5
1
vote
2 answers

Why is it returned when trying to execute the request Observable?

I am new to rxjs and am trying to do two requests. When I try to see the result, I get Observable. copy() { const obj = {}; this.create(skill) .pipe( mergeMap((res) => { return [res, forkJoin(this.levels.map((level)…
Vladislav
  • 125
  • 6
1
vote
1 answer

RxJS observables catch errors without the error callback

I am wondering if there is a way to able to catch a subscribe error on an observable without the error callback? For instance, you catch errors like this .subscribe({ next: (obj) => { // Placeholder for code }, // At the moment we need to…
user3428422
  • 4,300
  • 12
  • 55
  • 119
1
vote
1 answer

BehaviorSubject .next() is not emitting updated value

I just want to apologize for my lack of understanding of RxJS and Observables. I posted a question earlier but it was very poorly worded and I know it wasn't understandable, so after a day I think I can explain my issue better. The objective of my…
Donny groezinger
  • 127
  • 1
  • 3
  • 9
1
vote
2 answers

Mutating a RxJS observable with variable mutators - Angular

I made a service that gets some userdata from a remote source. The service a method for getting multiple users, and one for getting a specific user. The observables returned from the two methonds get .pipe(ed) thru a map() to be able to mutate the…