Advanced Applications
We’ve pushed the simple model of single application stage far enough to incorporate services, notifications, and even dashboard stages, but we need to move to a more advanced model to access the rest of the features. An advanced application will have some or all of these characteristics:
Use an application assistant as the main application entry point and for handling application initialization and coordination.
Create a primary card stage when launched.
Handle relaunch or remote launch requests through a defined
handleLaunchmethod.Post banner notifications and maintain a dashboard panel for events while not in focus or in the background.
Schedule wakeup requests through the Alarm service and handle the alarm callbacks in the background.
If you aren’t clear on the application lifecycle or the role of the application assistant, you may want to review Chapter 2 before reading the rest of this chapter.
Back to the News: App Assistant
This chapter began with a list of guidelines for developing multistage applications. News needs to be cleaned up to conform to those guidelines, so before creating the app assistant, we’ll make these changes to News:
Remove use of the global window object; change
window.setInterval()tothis.controller.window.setInterval().Use the local controller’s
stageControllermethods; instead ofMojo.Controller.stageControllermethods forpushScene, we’ll useswapScene, as in this example in storyView-assistant.js in thehandleCommandmethod:case "do-viewNext": ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access