ComponentLifecycleEvents
interface is implemented by classes that need to observe a particular
component's life-cycle events. module:caplin/component/Component
instances themselves automatically implement this
interface, since Component
extends ComponentLifecycleEvents
.
Component life cycle events are emitted by the object that hosts the components. This is either the top-level
module:caplin/component/frame/FrameManager
for the application, or any composite type component that itself
contains other components. Overriding any of the methods in this listener interface is optional, but doing so will
enable you to react to the related event.
The FrameManager
determines whether the event methods are called immediately before or immediately
after the event they refer to.
- Implementations:
- module:caplin/grid/refine/component/presenter/RefinerSummaryPresentationModel
- module:caplin/presenter/view/knockout/ComponentPluginFrame~ComponentPluginFrame
- module:caplin/presenter/view/knockout/ControlPluginComponentLifecycleListener~ControlPluginComponentLifecycleListener
Methods
-
onActivate()
-
Invoked when the frame becomes the active or focused frame within the page.
-
onClose()
-
Invoked when the frame containing this component is closed.
This method should be used to clean up any resources the component currently has open, including subscriptions and any other listeners that may have been registered. Once
onClose()
has been called no further methods will be called for this component.It is possible for the
onClose()
method to be invoked beforeonOpen()
if the component was instantiated but never displayed (for example if the user was not permissioned to view the component) in which case this method should only be used to clean up any resources it has opened within its constructor, and not those that it would have opened withinonOpen()
.- Implementations:
- module:caplin/grid/refine/component/presenter/RefinerSummaryPresentationModel#onClose
- module:caplin/presenter/view/knockout/ComponentPluginFrame~ComponentPluginFrame#onClose
- module:caplin/presenter/view/knockout/ControlPluginComponentLifecycleListener~ControlPluginComponentLifecycleListener#onClose
-
onDeactivate()
-
Invoked when the frame ceases to be the active or focused frame within the page.
-
onHide()
-
Invoked when a frame is no longer in view. It should stop or suspend any resources that may be processor intensive, such as subscriptions, so they are not active whilst the frame is hidden.
-
onMaximize()
-
Invoked when the frame has been maximized.
-
onMinimize()
-
Invoked when the frame has been minimized.
-
onOpen(nWidth, nHeight)
-
Invoked when the frame is first displayed. It will only ever be called once, which will always be after the
module:caplin/component/Component#getElement
method has been called on theComponent
.FrameManager
implementations must invoke this method after the element returned byComponent#getElement
has been added to the page. Initalisation code that needs to know the size of the component, or that uses the computed CSS styles that will only become valid after the component's HTML has been added to the view should be placed here.Parameters:
Name Type Description nWidth
int The width of the frame, in pixels. nHeight
int The height of the frame, in pixels. - Implementations:
- module:caplin/presenter/view/knockout/ComponentPluginFrame~ComponentPluginFrame#onOpen
- module:caplin/presenter/view/knockout/ControlPluginComponentLifecycleListener~ControlPluginComponentLifecycleListener#onOpen
-
onResize(nWidth, nHeight)
-
Invoked when the dimensions of the frame change.
Parameters:
Name Type Description nWidth
int The new width of the frame, in pixels. nHeight
int The new height of the frame, in pixels. -
onRestore()
-
Invoked when the frame has been restored from a minimized or maximized state.
-
onShow()
-
Invoked when a frame that has been hidden (see
module:caplin/component/ComponentLifecycleEvents#onHide
) is now back in view. It should restore any resources that were stopped or suspended byonHide()
.N.b. this method is not called when the component within the frame is first displayed, see
module:caplin/component/ComponentLifecycleEvents#onOpen
.