Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70779

How to use BehaviorSubject in an Ionic app with many variables?

$
0
0

@ioclaudio wrote:

Hi,
my question is about BehaviorSubject:

I’ve defined them in this way:

public mobileLatitude: BehaviorSubject<number> = new BehaviorSubject<number>(null);
public mobileLongitude: BehaviorSubject<number> = new BehaviorSubject<number>(null);
public mobileAltitude: BehaviorSubject<number> = new BehaviorSubject<number>(null);
public mobileHeading: BehaviorSubject<number> = new BehaviorSubject<number>(null);
public mobileSpeed: BehaviorSubject<number> = new BehaviorSubject<number>(0);
public mobileDataTimestamp: BehaviorSubject<number> = new BehaviorSubject<number>(null);

And I change them in this way:

this.mobileSpeed.next(location.speed);
this.mobileLatitude.next(location.latitude);
this.mobileLongitude.next(location.longitude);
this.mobileAltitude.next(location.altitude);
this.mobileDataTimestamp.next(tmstp);

Now, is it sure that they are modified in the order I wrote them?
That is when I manage the last Behaviour (mobileDataTimestamp), are the previous Behaviours already updated?

this.mobileDataTimestamp.subscribe((value) => {
....
});

The alternative is to use an object Location into a BehaviorSubject.
But is it possible to use an object into a BehaviorSubject?

Thank you very much

cld

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70779

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>