Track current and previous page IDs
masterThe library provides two public variables to manage page state:
currentPageId: Stores the ID of the currently loaded page. Use this to decide which components to update when the page changes.lastCurrentPageId: Stores the ID of the page that was active before the current one.
Pattern: Refreshing data on page change
To avoid sending unnecessary data, compare currentPageId with lastCurrentPageId. Only send refresh commands when they differ, then update lastCurrentPageId to match.
if(myObject.currentPageId != myObject.lastCurrentPageId){
if(myObject.currentPageId == 0){
// [send the data to refresh page0]
} else if(myObject.currentPageId == 1){
// [send the data to refresh page1]
}
myObject.lastCurrentPageId = myObject.currentPageId;
}