Questions tagged [rxjs-observables]

759 questions
2
votes
4 answers

Service without observables

I am struggling to understand , why i need to use observable. I have a very simple store like below @Injectable({ providedIn: 'root' }) export class DataService { private readonly personData: Person = new Person(); constructor() { } …
ishahrier
  • 93
  • 1
  • 10
2
votes
1 answer

Execute function after subscribers to an RxJS observable complete

In RxJS I need to execute some code after all subscriptions for a given observable have been executed. I need to do this after every single next notification that fires and after all subscriber functions have completed (not only once when the…
Sirion
  • 804
  • 1
  • 11
  • 33
2
votes
1 answer

Mapping an Observable in array items of another Observable, flattening the result

This title probably needs more explanation. Basically what I get from the backend is an Observable with an array of racedrivers, and to each of the array items, I want to map another property isOnTrack, which consists of another Observable (simple…
2
votes
1 answer

RxJS unsubscribe hook

Having a piece of code that fetches some data to a cache, and keeps it in sync using a websocket connection, and provides an access interface to the data using an Observable, how can I know that there are no subscribers to said data at one point in…
Ákos Vandra-Meyer
  • 1,890
  • 1
  • 23
  • 40
2
votes
2 answers

Angular RxJs Observable stream merge data

I'm trying to refactor my Angular code to be more "reactive" I have data returned from an Observable which retreives account data account$ into an object for example: { accountid: "123435", name: 'bob', customerId: "AR4533" ..etc} I also…
diyko
  • 23
  • 4
2
votes
2 answers

Angular template binding with Observable async pipe issue

Note I have created a simplified version of this question at Template binding with function return Observable and async pipe Template:
Gelin Luo
  • 14,035
  • 27
  • 86
  • 139
2
votes
1 answer

Setting selected item of a select element using async pipes in Angular

Angular experts! I'm trying to understand async pipes in Angular, but I'm stuck in a basic scenario. I have two select elements in the UI, one containing posts and one containing related comments. I want to set a posting (the last one) as the…
Frank Jusnes
  • 175
  • 1
  • 13
2
votes
1 answer

Angular + Ngrx : best practice to select a value in component and in function

I have pretty much the same question as in ngrx get value in function , but I'm wondering if the answer (see comment in that topic) is still the best practice nowadays. My situation is: I want to get 2 values from the store to show in my component…
bits
  • 672
  • 2
  • 7
  • 26
2
votes
2 answers

Wait for two observables (incl. failed one) before rendering template

I have two Observables. The rendering of the template should only start when BOTH Observables are completed or failed: Observable 1 completes and Observable 2 completes or Observable 1 completes, but Observable 2 fails When Observable 1 fails…
2
votes
2 answers

How to finilize rxjs switchmap observable?

I have an observable in my angular 8 project, and subscribing in ngOnInit(). export class ChartComponent implements OnInit { urlSubject: Subject = new Subject(); isLoading: BehaviorSubject = new…
barteloma
  • 6,403
  • 14
  • 79
  • 173
2
votes
2 answers

How do i use rxjs to ignore second,third button click till my first button click process is complete

My HTML has the following code: button (click)="doFunc()" In my ts-file I have the following: doFunc(){ this.service.executeAFuncWhichIsAsynchronous().subscribe(x => { updateMyUi(); }); } When I click the button twice, two service calls are…
2
votes
1 answer

Wait for data of a component to load before rendering the next component - Angular

I have to render a chain of components(say grids in blades) wherein after first component's data is loaded I will click on the data row of that component and it will open the next component. On click of data row of the next component, it will open…
Ora
  • 1,889
  • 2
  • 9
  • 9
2
votes
1 answer

Unsubscribe from observable timers that emit only once necessary?

In my program, I have a few timer(1000).subscribe() instances as well as some timer(1000, 1000).subscribe() parts. I was experiencing some memory leak issues and was wondering if I could alleviate those by unsubscribing from timers. Unsubscribing…
mneumann
  • 713
  • 2
  • 9
  • 42
2
votes
1 answer

How to get last value of observable by key using debounceTime

employeeChanged: Subject = new Subject(); setInterval(() => { this.employeeChanged.next(1); this.employeeChanged.next(1); this.employeeChanged.next(2); this.employeeChanged.next(2); this.employeeChanged.next(3); …
pr0metheus
  • 488
  • 6
  • 14
2
votes
1 answer

Angular 8 upgrade - typescript error - Type 'Observable>' is not assignable to type 'Observable'

I had a perfectly running code (and still running perfectly). When I upgraded from angular 7 to angular 8, my visual studio code started showing errors for HttpClient.get methods. The errors are coming in the catch part of the HttpClient.get…
Dhaval Chokshi
  • 113
  • 1
  • 9