Questions tagged [rxjs-observables]

759 questions
1
vote
1 answer

Angular firestore get document field as string

I know there is a ton of questions like this, but none of the solutions solve my problem. IVe been stuck on this for a while, and would really appreciate some help/guidance. I suppose there is something big I am missing in the ideas of observable,…
1
vote
4 answers

How to extract only certain properties of json, returning as an observable using rxjs

For example this is the json which I am receiving, { "events": [... ], "total": 12341, "students": [ { "id": 1, "first_name": "John", "last_name": "Apple" }, { …
pepega
  • 25
  • 8
1
vote
1 answer

Rxjs Subject not emitting data immediately

I have a service with a RXJS subject and i am assigning data to subject inside constructor doing an api call. This subject I am subscribing in a component template. Though the data is provided to the subject, it is not emitting immediately the first…
Niranjan
  • 77
  • 9
1
vote
1 answer

angular subscribe to changes only if previous value of the form control !== currentvalue of the formcontrol

I would like to call onDataChange() only if previous value of input / selection != current Value of input / selection. However I've noticed that it is still calling onDataChange() whenever put the cursor on the input field (but didn't change any…
user21
  • 1,261
  • 5
  • 20
  • 41
1
vote
2 answers

Unsubscribe to observable when navigating away from an onsen ui page

I have an angular 2+ app running onsen ui, I have setup some components as pages and I am using the ons-navigator to switch between them. The problem im having is that when im subscribed to an observable in an ons-page and the user navigates away…
1
vote
1 answer

Is there a way to perform static code analysis/linting for Angular memory leak?

Let's say the proper pattern in Angular to unsubscribe from an observable in a component is thus: Now let's say I forgot the .unsubscribe() call in ngOnDestroy(). Is there any linting rule I could set up to catch this, or it must strictly rely on…
Alex. A
  • 732
  • 1
  • 7
  • 13
1
vote
2 answers

rxjs: load many for many from 2 endpoints and merge into single Observable

I have one endpoint for getting list of users, and another for getting list of apartments for every user: getUsers() => Observable; getUserApartments(userId) => Observable` How do I merge the data from the two into single…
eagor
  • 9,150
  • 8
  • 47
  • 50
1
vote
1 answer

RxJS Overwrite Timer/Observable Best Practice

I am trying to "reset" a timer when a service emits a new Expiration time. I have it overwriting the observable. I am not sure if i should "garbage collect" the observable OR if there is a better way to "reset" the timer. This code works fine but i…
Ricardo Saracino
  • 1,345
  • 2
  • 16
  • 37
1
vote
1 answer

can i bind from event to custom component output

i am having a custom component export class SystemInputComponent implements OnInit, OnDestroy { @Input() ... @Output() enterFn: EventEmitter = new EventEmitter(); ... that has output that act as an event as i know and that…
Hassan Ahmed
  • 67
  • 1
  • 12
1
vote
3 answers

Angular with RxJS - Array's Reduce Function Not Working When Subscribed To An Observable

I have the following code and I'm trying to calculate the total of all items added to the cart. When I use reduce I don't get back anything but while troubleshooting I added a map in there (commented out code) and that prints a value. I can add more…
sayayin
  • 971
  • 5
  • 23
  • 36
1
vote
1 answer

Angular - How To Process an Observable in the Class

New to Angular. Wanted to learn how to manage state centrally so used ngRx. Also, have not used an Observable before so I am really stuck. Below is my code where the cart holds and array of objects. I just need to iterate over the cart which is…
sayayin
  • 971
  • 5
  • 23
  • 36
1
vote
1 answer

How to retrieve last value passed to next() of an Rxjs Observable outside the observer

I have a class with more than 30 observable attributes. Each time my server receives a payload containing these 30 attributes I call the next() method for all the corresponding attributes of the instance, so far so good. The problem is that,…
Teodoro
  • 1,194
  • 8
  • 22
1
vote
2 answers

Unhandled Promise rejection: You provided 'undefined' where a stream was expected. Using SwitchMap and a function of type Observable

this is my first time using switchMap from the rxjs library. Im guessing this error message means its unhappy with how I am doing things. Observe my addemail function addemail(form:NgForm){ …
user14150478
1
vote
2 answers

Chain Observable RxJs in Angular

I use RxJs 6.6.0 and Angular 9. I have two functions which returns Observable<'Class1'> and Observable<'number'>. so I use to: funcA().subscribe(x=>{ // do something...}); funcB().subscribe(x=>{// do somethings..}); But I need to call funcB only…
Arno
  • 91
  • 2
  • 11