Questions tagged [rxjs-observables]

759 questions
0
votes
2 answers

How do I switch between two Observables in order and have the subscription fire twice?

I am using RxJS. I have two Observables (API calls) that return a different amount of information for the same array. I want to switch between the Observables and have the subscription recognize both results, i.e. fire each time a value is…
ebakunin
  • 3,621
  • 7
  • 30
  • 49
0
votes
2 answers

Rxjs how to cache the result of an observable for a given argument?

In my app I use rxjs and I have a method that looks like this: query(queryString: string, silent = false): Observable { return this.sqliteService.dbQuery(queryString).pipe( tap(val => { if…
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
0
votes
1 answer

Rxjs: are the fromPromise and toPromise operations expensive?

In my TypeScript app I've reached the point where I have a method that internally does several fromPromise and toPromise operations: myMethod(...): Promise { return fromPromise(this.someService1.someMethod1(...)).pipe( …
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
0
votes
2 answers

Angular 8 Subscribe not getting the return data from service

I want to Patch the data to my forms after passing the ID to the service and getting the data on my SERVER but I don't get any data. here is my code addForm: FormGroup; ngOnInit(){ const routesParams=this.routes.snapshot.params; …
0
votes
1 answer

Converting old RxJS code to v6 : merge, filter, timer, map, first, toPromise()

Im trying to update this code to version 6 but I cannot figure out how rework the flow, from reading and playing around I think I need to pipe results etc but I cant see how it can be done using the flow of merge, filter, timer, map, first,…
Jipsum
  • 3
  • 5
0
votes
1 answer

How to find sum using reduce, pipe and combinelatest?

Values is list of obervables over input fields var example = combineLatest(values); How do I find sum of values in text field. example.subscribe(val => { console.log('Sum:', val); }); Having subscriber over it gives me output…
0
votes
1 answer

Rxjs Observable Issue

I have declared a subject in service and tried to push the response got by making a GET call to back end using "subject.next()"..also assigned an observable for the subject using "subject.asObservable()" and subscribed to the observable in two…
Ganesh
  • 21
  • 4
0
votes
1 answer

RXJS Nested dependant subscriptions

I'm trying to wrap my head around using Observables. But I'm struggling. I've googled this for a while, and i can't really decide if the examples i see do what i try to do. I'll try to explain it, so maybe someone can explain it to me. I have this…
larschla
  • 377
  • 1
  • 6
  • 15
0
votes
2 answers

Using RxJs ConcatMap don't send a value of null or empty string

I am using RxJs concatMap to control the saving of some data in my application. this.myService.saveData(this.updatedData) .pipe( tap(data1Res => this.onData1Success(data1Res)), concatMap(() => this.myService.saveOne(this.OneData)), …
Funn_Bobby
  • 647
  • 1
  • 20
  • 57
0
votes
1 answer

Does this observable leak memory?

I'm fairly new to observables and according to this article. The examples below leaks memory. However, I saw tonnes of tutorials online showing examples like this. someObservable.subscribe(data => { // do something }); Does the code above leak…
John
  • 411
  • 2
  • 8
  • 22
0
votes
1 answer

Synchronous RxJs unsubscription not working

Demo: https://stackblitz.com/edit/rxjs-unsubscribe-issue?file=index.ts Below code is not working Error: Cannot read property 'unsubscribe' of undefined const a = (): Observable => new Observable(sub => { sub.next(1); …
0
votes
2 answers

rxjs - change single data in two different subscribes - make more reactive

I am pretty new in Angular2+ and RxJs, so I apologise if I am asking some obvious things. Functionality When the data is just started to load, startAction is getting emitted, isLoaded turns false and the spinner is getting shown. Once the data is…
Dzmitry Alifer
  • 409
  • 1
  • 6
  • 17
0
votes
1 answer

Angular subscription getting undefined in local variable

I have a local variable and want to use the Observable in our Angular Component just to subscribe to it and store the response locally,but some how its getting undefined always.Any clues why its not assigning? export class ScheduleHistoryComponent…
Avinash.Byalihal
  • 137
  • 2
  • 7
  • 22
0
votes
1 answer

how to combine observables to one ignoring errors in rxjs

I have several observables and want to combine them to one but want to ignore those which emits errors, I want the operator to emit values for successful observables even if some of them emits an error. I was looking for operators like concat,…
Rishabh Gusain
  • 683
  • 1
  • 6
  • 23
0
votes
1 answer

Looping through data from Angular subscription

I have a an inelegant solution to a problem I'm having looping data from an observable. I would like to know the correct way to do it because this doesn't seem right to me. I am dynamically creating a form using the response from an api call This is…
mr_j
  • 125
  • 1
  • 15