How to get previous page instance after onResume event triggered


#1

Guys,

I have to call the class’ method startTimer() when onResume is triggered, but the app has to load the previous page instance because, to be able to execute this method properly, some variable has to be well defined.

// other imports here
import * as application from "application";
import * as frame from "ui/frame";

export class ETAComponent {
// class code here

// timerReloadPageETA and timerETA variables are defined outside the class
// the method this.getItinerariesETA(); gets data from server and has a lot of code, logic and access to class variables here

// method that I must call when onResume is triggered
    startTimer() {
        if ( !timerReloadPageETA ) {
            timerReloadPageETA = timerETA.setInterval( () => {
                this.getItinerariesETA();
            }, 30000);
        }
    }

}

// after class code:
application.on(application.resumeEvent, function (args) {
    if ( frame.topmost().currentPage != null ) {
        var viewId = frame.topmost().currentPage.getViewById( "etaPage" );
        if ( viewId != null && viewId.id === "etaPage" ) {
            console.log( "You are at ETA Page" );
            new ETAComponent(null, null, null,).startTimer();
        } else {
            console.log( "You are at any other place but ETA Page" );
        }
    }
});

I guess I must change this line new ETAComponent(null, null, null,).startTimer(); to get it works. My question is: for what should I change it?

Any idea?

Thanks