Hello,
I am coding a static method (class method) that is intended to be called during the platform initialization
this.platform.ready()
.then(...)
I need to publish an event in the callback method, however, due to the method being static, the normal way of injection by constructor signature does not work.
there are two possible alternatives as I can see:
1: new Events().publish(…) , ( as you can see in the code below)
2, I checked the Events.d.ts; and found out that there is a class method Events.setupEvents()
static geoConfig(){
BackgroundGeolocation.configure(
(loc) => {
// Shall I use New Events() here? or Events.setupEvents
//new Events().publish(Cons.EVT_HI_GEO, new Position(loc.latitude,loc.longitude));
BackgroundGeolocation.finish(); // FOR IOS ONLY
BackgroundGeolocation.stop();},
(error) => {
new Events().publish(Cons.EVT_HI_GEO, new GeoError(error.code, error.message));
BackgroundGeolocation.finish(); // FOR IOS ONLY
BackgroundGeolocation.stop();},
Geo.config);
}
my question: which one shall I use? what more, are there any example?
please advise,
thanks