Pages form the bulk of an app. A Page instance contains the following:
pageId string that is used for page lookup and navigation.ctl.createPage(info)
Pages are created using the ctl.createPage() factory function.
close()
The Controller calls the close() method when the page is dismissed. The page can use it to remove event listeners or do other cleanup from open(). The default close() method does nothing.
component()
The Nav page or other navigation component calls the component() method to retrieve a Component subclass that will display this page's content in the View. The default component() returns a Component class whose Component render() method returns the results of calling the Page instance's render() method. Therefore, a page can supply a simpler render() method instead of implementing a full Component subclass.
A Component subclass.
deactivate()
The Controller calls the deactivate() method when a new popup page is opened on top of this page. It returns the state values required to restore this page's state when the pages on top are dismissed. The default deactivate() method returns null.
Any JavaScript type. This value is used as the state argument for reactivate(state) when the page is reactivated.
getSavedState(state)
The Controller calls each page's getSavedState() method when the application state is being saved to local device storage or in the cloud. The method adds the information required to restore the page's state variables to the state object.
The default getSavedState() method adds the information for the page's state variables marked for saving locally or globally (see getSavedSvs()). State variables that are unit siblings other than the current unit are excluded. The value stored for each state variable's ID key is the result of calling the state variable's getSavedState() method.
state (optional)The state object.
getSavedSvMonitors()
Returns the array of SvMonitors for the state variables returned by getSavedSvs(). The array is created the first time the method is called and then reused. Used by the default hasChanged() method.
getSavedSvs()
Returns the array of the page's state variables that are marked for saving locally or globally (their save property is 'local' or 'global'). Unit siblings are included only for the current unit. The list is recomputed on every call because it depends on the current unit. The default getSavedState() and setSavedState() methods use it.
hasChanged()
The Controller calls the hasChanged() method after each synchronization to determine whether the page's saved state has changed, and so whether the app state needs to be saved. It is unrelated to Model recomputation. The default hasChanged() method uses the SvMonitors for the state variables marked for saving locally or globally (see getSavedSvMonitors()). It interrogates every monitor, so each is current for the next inquiry, and returns true if any of their hasChanged() methods returns true.
True if the page's saved state variables have changed since the last time hasChanged() was called, otherwise false.
init()
The Controller calls the init() method after the application is fully loaded on startup and all application pages and their associated state variables are created. The state variables hold their default values because the previous session's values are restored after all pages are initialized. This allows the page to do any pre-setup before being opened.
open(arg)
The Controller calls the open() method when a page is opened. This allows the page to do any pre-setup before Model computation. The default open() method returns an empty string.
If the info object passed to ctl.createPage() supplies its own open(), the Controller wraps it so that it also sets the page's isOpen and isActive properties. The same applies to close(), reactivate(), and deactivate(), so those methods need not maintain the two properties themselves.
argnav.popupPage(pageId, arg)). A JavaScript type expected by the page. See also takesOpenArg.A Template, a Component, or a string that is the content to display, as for render().
reactivate(state)
The Controller calls the reactivate() method when the popup pages above the page are dismissed, and the page is now the topmost page. The state argument is the value the deactivate() method returned previously for this page.
statedeactivate() method.render()
The default component() returns a Component class whose Component render() method returns the results of calling the Page instance's render() method. Therefore, a page can supply a simpler render() method instead of implementing a full Component subclass.
A Template object, a string, a number, a DOM node, a Component object, or an array containing a mix of these types that represents the contents of the page when opened.
renderHelp()
When initialized, the built-in Help page automatically collects the templates returned by calling the renderHelp() method. It then uses that information, along with the page's pageId and title, as a help topic.
A Template object, a string, a number, a DOM node, a Component object, or an array containing a mix of these types that represents the help information displayed when the page is selected as the help topic.
renderTold()
Optional. A page that contributes to the emailed flight planning results (TOLD) defines this method. The told module calls it for each page in its toldPageIds list, converts the result to plain text, and mails the text from the Email button.
A <PlainText> template containing one <Pl> element for each line of text. See Writing a page's TOLD lines.
isSpinning(name)
Returns true if the named spinner is running. A RefreshButton uses it when it renders so that a re-render while a fetch is in progress keeps spinning.
nameA Boolean.
registerSpinner(name, comp)
Adds a RefreshButton component to the set that is synchronized with the named spinner. The component calls this when it mounts.
namecompsetSavedState(state)
If state is null, all of the page's saved state variables are reset to their defaults.
The Controller calls each page's setSavedState() method when the application state is being restored from local device storage or from the cloud. The method uses the information in the state object to restore the page's state variables. The state object uses the state variable ID as a key for each state variable's information.
The default setSavedState() method restores the state of the page's state variables marked for saving locally or globally. The state is restored by calling the state variable's setSavedState() method passing the state object's value for the state variables. A state variable that is missing from state is set to its default value. If the restored value is invalid and the state variable has no options, it is also set to its default value.
statestartSpinner(name)
Starts the named spinner on this page to show that a fetch is in progress. A page may have more than one spinner, so each is named for the thing it is refreshing (e.g., 'metar'). The name matches the spinner property of the RefreshButton components on the page. Starting a spinner that is already running, or one with no button rendered, does nothing.
namestopSpinner(name)
Stops the named spinner on this page.
nameunregisterSpinner(name, comp)
Removes a RefreshButton component from the set synchronized with the named spinner. The component calls this when it unmounts.
namecompupgradeSavedState(state, version)
The Controller calls each page's upgradeSavedState() method after the application state to be restored has been retrieved from local device storage or from the cloud. The method updates the page's state variable information in the state object as required to upgrade the information of the information saved by an older application version to the current application version. The method interprets the version string and updates the relevant keys and values as required.
See also:
stateversion. See [versionCompare()`](utilities/utilityfunctions.md#versioncompare)Returns true if the upgrade was successful. Returns false if the information was corrupt or too old.
computeInfoThe computeInfo array from the info object passed to ctl.createPage(). Defaults to an empty array.
An array.
isOpenTrue if the page is opened, whether activated or deactivated.
A Boolean.
isActiveTrue if the page is opened and activated.
A Boolean.
pageIdThe page's ID.
A string.
stateVarInfoThe stateVarInfo array from the info object passed to ctl.createPage(). Defaults to an empty array.
An array.
tipInfoThe tipInfo array from the info object passed to ctl.createPage(). Defaults to an empty array.
An array.
svA state variable namespace containing the state variables whose IDs have this page's pageId prefix. The Controller creates it at startup.
An object.
takesOpenArgTrue if the page's open() method declares an argument, meaning that a navigation reference such as cb.NAME passes it its argument.
A Boolean.
titleThe page's title. Defaults to an empty string.
A string.