Questions tagged [rxjs-observables]

759 questions
3
votes
1 answer

RxJS - Using pairwise to confirm and revert input field

So I'm a little new to observables, I'm struggling with a scenario, and I thought it might be a good candidate for an SO question. Here we go... The scenario is this: I have a drop-down field; when it is changed, I want to check a condition based…
3
votes
1 answer

Template binding with function return Observable and async pipe

Note this is simplified question of Angular template binding with Observable async pipe issue template:
{{foo()$ | async}}
source code: import { Component } from "@angular/core"; import { BehaviorSubject, of, Observable } from…
Gelin Luo
  • 14,035
  • 27
  • 86
  • 139
3
votes
1 answer

How cancel angular http request made in RXJS Effects

I want to cancel the http request made in RXJS effects in angular 8. @Effect() getReport$ = this.action$.pipe( ofType(ActionTypes.GET_WIDGET), map(toPayload), mergeMap(payload => { return this.dashboardService.getReport(payload).pipe( …
3
votes
0 answers

How and when does a Subscription on an Observable get automatically unsubscribed?

I want to know, when to unsubscribe on a Observable Subscription. And when there is no need to unsubscribe. It is kind of hard to understand the concept of the subscriptions. I give you an example: this.http .get( environment.baseUrl +…
Luxusproblem
  • 1,913
  • 11
  • 23
3
votes
3 answers

rxjs: Combine result of observables while already displaying the first with async pipe

What is the best way in angular with rxjs to already display the result of a first observable, and combining the data when other observables are finished? Example: @Component({ selector: 'app-component', template: `
devqon
  • 13,818
  • 2
  • 30
  • 45
2
votes
2 answers

How to re-render a component when data changes Angular js

I have three components: userlist page, userdetails page, and inside userdetails there is a subcomponent (Child) that displays a list of users like (Related), when I enter user1 I see his name and email and on the other side there is a that will…
Rakh
  • 33
  • 3
2
votes
2 answers

RxJS: Ensure Optional Object Property is Defined

I need a RxJS operator that can check that if a property on an object exists, and then change the type to correctly reflect this. I already have an operator that will do this for an emitted value: const notUndefined = () => filter
Mikkel R. Lund
  • 2,336
  • 1
  • 31
  • 44
2
votes
1 answer

RxJS call function 1 second after subsccribe to an observable

Lets say I have an angular http Observable. I'm not sure is it going to resolve after 100ms or 5 seconds and I would like to trigger a loading spinner if the delay is more than a second. Is someone know an elegant way to do that? I was thinking that…
Kaloyan Stamatov
  • 3,894
  • 1
  • 20
  • 30
2
votes
1 answer

RXJS SwitchMap not working properly with Resolver after Angular Upgrade

I have a component where a user chooses a report type to generate. The component.ts function is like so: generateReport(reportType, projectReport) { this.showSpinner = true; if(reportType === 'project-weekly-report') …
Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73
2
votes
1 answer

How to replicate a promise chain in Angular using Observable?

I'm new to angular and migrating a project from angularJS to angular. I'm having below issue with the existing flow. 1.authcomponent: function FuncBasedOnLogin() { authServices.hasLoggedIn(dataService.dataModel.tenant).then(function (isLoggedIn) …
2
votes
1 answer

forkJoin on NestJS not working after migration to newer version

I'm running nestjs application and have a peace of code that using forkJoin const results: string[] = []; const args = ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6']; .... switchMap(() => { const setToHandle = []; args.forEach(arg =>…
2
votes
1 answer

How to simplify nested HTTP calls that use mergeMap

I need to sequentially call multiple HTTP requests. Currently I have this huge epic where I pass all API requests and then try to fire them one by one using mergeMaps. It works, but I believe there must be some easier or cleaner way but. All I found…
bdobry
  • 190
  • 1
  • 8
2
votes
2 answers

Ordering RXJS streams by data property

I have an issue where I'm attempting to order multiple distinct streams from a time series database. Assuming that all the data in each stream is sorted by timestamp, given the following code how would I modify streams dataA$ and dataB$ such that…
Josh C.
  • 370
  • 2
  • 8
2
votes
1 answer

Best practices for avoiding memory leaks in angular

I'm trying detect and fix potential memory leaks in my angular/spartacus application. So basically I'm looking for any "subscribe(..." calls in my code base and evaluate what I can do. I know that simplest form is simply to use observables directly…
2
votes
1 answer

how to pass data between concatmap in RXJS Angular

I have a pipe on a observable, the code is like below: .pipe( concatMap(() => this.security.getUser()), tap((partyId) => { if (!partyId) { window.location.assign(`${environment.redirectURL1}/dashboard/login`); …