new Screen()
Screen class is a special type of route handler that provides helper
utilities that adds lifecycle and methods to provide content to each
registered surface.
Extends
Members
-
<protected, non-null> cache :Object
-
Holds the cached data.
Type:
- Object
- Inherited From:
- Default Value:
-
- null
-
<protected> cacheable :boolean
-
Holds whether class is cacheable.
Type:
- boolean
- Inherited From:
- Default Value:
-
- false
-
<protected> id :string
-
Holds the screen id.
Type:
- string
-
<protected, nullable> title :string
-
Holds the screen title. Relevant when the page title should be upadated when screen is rendered.
Type:
- string
- Default Value:
-
- null
Methods
-
<static> isImplementedBy(object)
-
Parameters:
Name Type Description object
* Returns:
Whether a given instance implementsScreen
.- Type
- boolean
-
activate()
-
Fires when the screen is active. Allows a screen to perform any setup that requires its DOM to be visible. Lifecycle.
-
addCache(content)
-
Adds content to the cache.
Parameters:
Name Type Description content
string Content to be cached. - Inherited From:
-
beforeDeactivate()
-
Gives the Screen a chance to cancel the navigation and stop itself from being deactivated. Can be used, for example, if the screen has unsaved state. Lifecycle. Clean-up should not be preformed here, since the navigation may still be cancelled. Do clean-up in deactivate.
Returns:
If returns true, the current screen is locked and the next nagivation interrupted.- Type
- boolean
-
beforeUpdateHistoryPath()
-
Gives the Screen a chance format the path before history update.
Returns:
Navigation path to use on history.- Type
- string
-
beforeUpdateHistoryState()
-
Gives the Screen a chance format the state before history update.
Returns:
History state to use on history.- Type
- object
-
clearCache()
-
Clears the cache.
- Inherited From:
-
deactivate()
-
Allows a screen to do any cleanup necessary after it has been deactivated, for example cancelling outstanding requests or stopping timers. Lifecycle.
-
disposeInternal()
-
Dispose a screen, either after it is deactivated (in the case of a non-cacheable view) or when the App is itself disposed for whatever reason. Lifecycle.
- Overrides:
-
evaluateScripts(surfaces)
-
Allows a screen to evaluate scripts before the element is made visible. Lifecycle.
Parameters:
Name Type Description surfaces
object Map of surfaces to flip keyed by surface id. Returns:
This can return a promise, which will pause the navigation until it is resolved.- Type
- CancellablePromise
-
evaluateStyles(surfaces)
-
Allows a screen to evaluate styles before the element is made visible. Lifecycle.
Parameters:
Name Type Description surfaces
object Map of surfaces to flip keyed by surface id. Returns:
This can return a promise, which will pause the navigation until it is resolved.- Type
- CancellablePromise
-
flip(surfaces)
-
Allows a screen to perform any setup immediately before the element is made visible. Lifecycle.
Parameters:
Name Type Description surfaces
object Map of surfaces to flip keyed by surface id. Returns:
This can return a promise, which will pause the navigation until it is resolved.- Type
- CancellablePromise
-
<protected> getCache()
-
Gets the cached content.
- Inherited From:
Returns:
Cached content.- Type
- Object
-
getId()
-
Gets the screen id.
Returns:
- Type
- string
-
getSurfaceContent(surfaceId)
-
Returns the content for the given surface, or null if the surface isn't used by this screen. This will be called when a screen is initially constructed or, if a screen is non-cacheable, when navigated.
Parameters:
Name Type Description surfaceId
string The id of the surface DOM element. Returns:
This can return a string or node representing the content of the surface. If returns falsy values surface default content is restored.- Type
- string | Element
-
getTitle()
-
Gets the screen title.
Returns:
- Type
- string
-
isCacheable()
-
Whether the class is cacheable.
- Inherited From:
Returns:
Returns true when class is cacheable, false otherwise.- Type
- boolean
-
load( [path])
-
Returns all contents for the surfaces. This will pass the loaded content to
Screen.load
with all information you need to fulfill the surfaces. Lifecycle.Parameters:
Name Type Argument Description path
string <optional>
The requested path. Returns:
This can return a string representing the contents of the surfaces or a promise, which will pause the navigation until it is resolved. This is useful for loading async content.- Type
- CancellablePromise
-
setCacheable(cacheable)
-
Sets whether the class is cacheable.
Parameters:
Name Type Description cacheable
boolean - Inherited From:
-
setId(id)
-
Sets the screen id.
Parameters:
Name Type Description id
string -
setTitle( [title])
-
Sets the screen title.
Parameters:
Name Type Argument Description title
string <optional>
<nullable>
-
toString()
-
Returns:
- Type
- string