Questions tagged rxjs

Explore the latest questions and answers asked by our top developers.

switchMap inside pipe() VS sequence of switchMap

I didn’t get if there is a difference between this: Observable.pipe( switchMap((res) => { … }), switchMap((res) => { … }) ); and this: Observable.pipe( switchMap((res) => { … }).pipe( switchMap((res) => { … }), ) ); Can you help me understanding if there is differences in the way data are treated? Thank you Source: […]

By Matt
Published
Categorized as angular, rxjs Tagged ,

Cannot force change Detection in Loading Bar Component

I’m having a tough time understanding why I cannot get a progress bar to show up correctly in my app. I have tried several things to force change detection, and to just see what is going on. Below is the scenario. I am going through a list of Objects and formatting them, as I am […]

By Willie
Published
Categorized as angular, angular-changedetection, rxjs Tagged , ,

AngularFireAuth.user observable won’t emit when placed in withLatestFrom RxJS operator

The AngularFireAuth.user observable works fine if it is the source observable e.g. this.AngularFireAuth.user.subscribe((u) => console.log(u)) but blocks my observable stream if I place it in the withLatestFrom operator, e.g. of("test") .pipe( tap(console.log), // log showing up withLatestFrom(this.AngularFireAuth.user), tap(console.log) // log not showing up ).subscribe() What am I doing wrong and how can I get around […]

RxJS combineLatest: Unable to merge with latest values in Angular 12

I have 3 filter values (select boxes basically). When there is a selection change, I want to fire a combined API call along with other filter values selected previously (using BehaviorSubject for each filter). Unfortunately, in the ‘combineLatest’ I can see only 1 filter value. Other values from other subjects are disappearing. Please help me […]

Need Angular 8 canActivate to return Observable<boolean> of a Subject

So I have an Angular 8 application that uses cookies to handle authentication (Laravel server using Laravel Sanctum). Because I am using cookies and I dont store any user data/tokens in localStorage, I have to fetch the current user from my server every time my app initializes using a stored cookie. auth.service.ts export class AuthService […]

By amcardwell
Published
Categorized as angular, http, javascript, rxjs Tagged , , ,

map and filter on observable return empty result

I write an angular 12 application with rxjs that has a products categories list as a service stored in an observable, i am trying to create an observable that will return that categories that has an empty parent_category_id, the problem is that this observable returns an empty list. this is my product category service: import […]

By ufk
Published
Categorized as angular, observable, rxjs Tagged , ,

How to automatically display the new record to a list when a new record is added in Angular?

I’m currently doing an Angular app with CRUD operations and Springboot API as a back end. The problem is when I add a new user, it successfully added but it does not automatically display on the List. It needs to reload the page to show the updated list. Here’s my add-user.component.ts: import { Component, OnInit […]

infinite http request loop when it’s inside a data service observable and its response used to call a function inside the outer data service (angular)

I want some data that’s inside a data service and is an observable, when I subscribe to the data, I then make an HTTP request and send the data along with it. When the response is received, I then subscribe to it and try to call a function inside the same data service. Here’s the […]

By Ahmad
Published
Categorized as angular, javascript, observable, rxjs Tagged , , ,

Angular BehaviourSubject in UIService and 2 Components subscribing twice

I have an app with 2 components app and home. In app I have a side menu which when an item is clicked it updates a behaviorSubject in a UIService I am using as a simple store. In home component I subscribe to the store and am currently just logging it to the console. Every […]

By Bwizard
Published
Categorized as angular, rxjs Tagged ,

RXJS: Create and chain a dynamic array of filters

I’m trying to create a service that can dynamically filter a stream of Record<string, unkonwn> by it’s keys. The idea is I can call like an "addFilter" on the service and pass an observable with a filter which is then stored in an array of observables in the service. Then when the observable of Records […]

By Brandon
Published
Categorized as angular, rxjs Tagged ,
1 173

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq