Questions tagged [rxjs-subscriptions]

29 questions
7
votes
6 answers

Angular better way to clear subscriptions

There are many ways to handle multiple subscriptions efficiently in a component, I have 2 ways here and wanted to know which is more efficient and why?? Method 1: Using Array Step 1: creating Array private subscriptionArray: Subscription[]; Step 2:…
Varun Sukheja
  • 6,170
  • 5
  • 51
  • 93
5
votes
2 answers

Angular - http interceptors - http rate limiter - sliding window

I am having a use case where I need to limit the number of outgoing http requests. Yes, I do have rate limiter on the server-side but a limit on the number of active http requests is also need on the front end too.For that reason I am attempting to…
2
votes
2 answers

How can I subscribe to a different service method using a conditional statement?

Can't figure out how to subscribe to the desired method of an Angular service depending on the conditional statement // this.someService.someMethod depending on the conditional statement .pipe(takeUntil(this.unsubscribe$)) .subscribe((items)…
2
votes
3 answers

how to subscribe in a conditional subscription result

I'm trying to perform 3 async actions (observables), one inside the other. 1. The first observable is the response of a modal dialog eventEmiter - the rest of the flow is depended on its response (let say that the modal return boolean emiter…
Guy E
  • 1,775
  • 2
  • 27
  • 55
2
votes
1 answer

Angular 8 do I need to subscribe to a request if I don't care about the response

I hope this makes sense. I have decided to change the way some of my services are working simply because it was becoming a bit cumbersome to subscribe to responses and handle creates, updates and deletes in different views. So I decided to make a…
r3plica
  • 13,017
  • 23
  • 128
  • 290
2
votes
2 answers

Adding pipes after subscribing to a push notification service

Situation: I've encountered a use case for the rxjs Observable system, where I may need to add piped commands to a Subscription after it has been started. In my case, the application I'm working on has to passively listen to a push notification…
Andrew Gray
  • 3,756
  • 3
  • 39
  • 75
1
vote
2 answers

Is it possible to write an rxjs operator that controls subscription to it's source?

Let's say I have an observable source that has the following properties: It makes a network request the first time it's subscribed to It's idempotent, so it will always emit the same value after it's first subscribed to It's low priority, so we…
1
vote
0 answers

calling subscribe in the parent component doesn't work, but does work in child component rxjs angular

I have a parent chat-app component that renders two chat component, and i listen for changes in a service from the parent component using subcribe. Not sure why but when I subscribe in the child component the subscribe work and get to the…
shakedk
  • 71
  • 1
  • 6
1
vote
2 answers

Subscribe in subscribe in Angular rxjs

I have: getSth(): void { this.service.functionName.pipe( takeUntil(this.destroy$), distinctUntilChanged(), map(res => res.event) ).subscribe(((response) => { this.getAnother(response); })); …
1
vote
2 answers

RxJS subscription in Angular component

I don't completely understand where and how I need to declare observables / subjects in Angular component. Currently I develop a website which interacts with MovieDB API and I have everything working, but at the same time I understand that my code…
1
vote
2 answers

*ngFor simply not working with array of Objects

I have the TS code getItems().subscribe(val=>{ this.items=val; }) which works fine. When I console.log(this.items) I get "array:0{size:XL,quantity:1}" Buuut. Amazingly, something I've never dealt with before in angular, when I run the code in the…
1
vote
2 answers

Should i unsubscribe from ActivatedRoute when calling subscribe method within a Router subscription?

I've read that normally you don't have to unsubscribe from Router or ActivatedRoute explicitly because: The ActivatedRoute and its observables are insulated from the Router itself. The Router destroys a routed component when it is no longer needed…
Maurice
  • 6,698
  • 9
  • 47
  • 104
1
vote
1 answer

RXJS avoid nested multiple subscriptions

I would like to transform below code snippet: this.dataUserSubscription = this.store$.pipe(select(selectUser)).subscribe( user => { this.store$.pipe(select(selectUserData, {user}), take(1)) …
user10239144
1
vote
2 answers

Angular RxJS - Need to Wait until Subscribe has finished in other method

@Component({ selector: 'note-consultant', template: '
{{patientInformation}}
' }) export class NoteConsultantComponent implements…
1
vote
1 answer

Angular: How to prevent component template from flashing both conditional statements?

I'm trying to stop my component template from flashing both conditional statements when the condition changes after the component is initialized. My application receive a token and according to it's validity it displays the necessary content in the…
1
2