Which method can I use instead of the event used in ionic-v3 ?
// send
//receive
Which method can I use instead of the event used in ionic-v3 ?
// send
//receive
Look at observables here.
They are a better and more generic want of creating a pub/sub system.
Using an event provider has solved for me. Here’s an example.
…
import { Injectable } from ‘@angular/core’;
import { Subject } from ‘rxjs’;
@Injectable()
export class EventsProvider {
private dataCompanySubject = new Subject();
publishDataCompany(data: any) {
this.dataCompanySubject.next(data);
}
observeDataCompany(): Subject {
return this.dataCompanySubject;
}
}
And use like this
…
this.eventsProvider.publishDataCompany(true);
and
this.eventsProvider.observeDataCompany().subscribe((data: any) => {…
I want to receive data sent on page 1 on page 2. And the data format is (key, value). How can I do it?
Follow @daniel_rf121 recommendation. Read more here https://medium.com/wizpanda/dealing-with-breaking-change-in-ionic-5-db3ba711dfcd
And also read on about observables…
That should get you started.
As I explained above, you can pass objects, and all pages that are listening to this observable, will receive this value.