Questions tagged [rxjs-observables]

759 questions
1
vote
1 answer

You provided 'undefined' where a stream was expected. Error in HttpInterceptor

I have seen and tried a lot of other threads describing the same issue, but couldn't find the solution. I am a beginner in angular technology. I am using angular 11. I am trying to refresh the JWT token in the HttpInterceptor…
1
vote
1 answer

Handling two HTTP requests (Angular + RxJS)

This is my first angular project, and I'm still not familiar that well with Observables and RxJS. In my project, at first I want to fetch all notifications with get request. After that, I want to take id of the last notification, so I could send…
user13067004
  • 131
  • 1
  • 1
  • 5
1
vote
0 answers

Not receiving events from subscribing to observable across modules

I'm using Angular 9. I have a root NgModule called AppModule which bootstraps the AppComponent that houses the core layout and frame of my app. In AppModule, I also import NotificationComponent which visually displays notifications by subscribing to…
ajgisme
  • 1,615
  • 2
  • 14
  • 28
1
vote
2 answers

rxjs - how can you create another observable from an observable but ignore its output in the parent observable?

I have a situation where I have an observable, and for each emitted item, I want to create another observable, but ignore that observable's value and instead return the result of the first observable. For example, if I click a button, I want to…
Oved D
  • 7,132
  • 10
  • 47
  • 69
1
vote
1 answer

How to avoid nested subscriptions with concatMap in Angular

I get an array of products with this code proyecto$:Observable this.proyecto$=this.http.get(`${this.urlProyecto}/${this.proyectoId}`) .pipe( map(p => { id: p.id, descripcion: p.name, …
kintela
  • 1,283
  • 1
  • 14
  • 32
1
vote
1 answer

Undefined value for the currentUserObj using Subject in rxjs in angular

I am using a subject in rxjs to pass data from my login component to the user-profile component but what happens is in my login component I call the sendUser method in the login component then in the user-profile component I subscribe to the…
lizardcoder
  • 336
  • 3
  • 6
1
vote
1 answer

How can of([1,2,3]).pipe(concatAll()) emit 3 values when of([1,2,3]) emits one?

of([1,2,3]).subscribe(console.log) prints:[1,2,3] But: of([1,2,3]).pipe(concatAll()).subscribe(console.log) prints: 1 2 3 Why the above happens? Why adding concatAll() emits the elements of the array one by one? Isn't this somehow the opposite of…
Marinos An
  • 9,481
  • 6
  • 63
  • 96
1
vote
1 answer

Angular: Subject behaviour different when using forkJoin

Folks, can anyone explain this behaviour? This is working: this.sessionService.current$.subscribe(session => { console.log('WORKING', session); }); But this is NOT working: forkJoin([ this.sessionService.current$ ]) .subscribe(([ …
Luke1988
  • 1,850
  • 2
  • 24
  • 42
1
vote
2 answers

How to create an observable that skips emissions between 2 events

The context is that of a musical piano. I am interested in catching key-up events that occur when the sustain pedal is not pressed. I have these streams: pedalDown$ pedalUp$ keyUp$ How can I pipe these together into an observable unsustainedUp$…
Hoff
  • 38,776
  • 17
  • 74
  • 99
1
vote
1 answer

Cancel repeated subscription in mergeMap

How to combine the distinct, switchMap and mergeMap operators, so that when the source emits repeated values (detected by distinct.keySelector), the previous subscription is canceled (as in the switchMap), but if the value is not repeated follow the…
Alex Parloti
  • 668
  • 1
  • 9
  • 25
1
vote
1 answer

Is there any way to convert event emitted by child component using @output into observable stream in parent

To emit any click from child to parent we can make use of @output in the child and in parent html we can listen to that event using the way shown below in parent we can write method addItem($event)…
Darpan
  • 234
  • 3
  • 15
1
vote
2 answers

Throttle based on a previous Observable

I have the following setup, which, every 3 seconds would make a new HTTP request to a server. getData(param1: string): Observable { return timer(0, 3000).pipe( switchMap(() => this.http.get(param1)) ); } If a given request…
1
vote
1 answer

How to insert an initial value for an async list in an ng-select (Angular 2+, ng-select, and rxjs)

I am using ng-select and specifically using typeahead to fetch the list from the server as user types. like this: defining an observable of Agents list to subscribe to whenever a string is inserted agents$: Observable agentsInput$ = new…
1
vote
1 answer

How to control what Observables to run in Angular

I hope you can help me to understand my problem, I have a problem with RXJS and Angular, I try to avoid that the call of an observable is activated using an if condition but in the execution of my website it is executed even if the condition is…
Joeyjofer
  • 33
  • 6
1
vote
2 answers

What is an elegand solution to iterate (and apply some logic) on an Observable containing an array using RxJS?

I am not so into RxJS and I have the following doubt about why it is the best way to solve this problem. I will try to explain it in details. Into a service class I have these 2 methods: acceptArtistBid(bid): void { …
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596