The ComponentLifecycleEvents
interface is implemented by classes that need to observe a particular
component's life-cycle events. module:ct-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:ct-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.
Methods
on Activate()
Invoked when the frame becomes the active or focused frame within the page.
on Close()
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 before onOpen()
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 within onOpen()
.
on Deactivate()
Invoked when the frame ceases to be the active or focused frame within the page.
on Hide()
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.
on Maximize()
Invoked when the frame has been maximized.
on Minimize()
Invoked when the frame has been minimized.
on Open(nWidth, nHeight)
Invoked when the frame is first displayed. It will only ever be called once, which will always be after the
module:ct-component/Component#getElement
method has been called on the Component
.
FrameManager
implementations must invoke this method after the element returned by
Component#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. |
on Resize(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. |
on Restore()
Invoked when the frame has been restored from a minimized or maximized state.
- See:
on Show()
Invoked when a frame that has been hidden (see module:ct-component/ComponentLifecycleEvents#onHide
) is now back in view. It should restore any resources
that were stopped or suspended by onHide()
.
N.b. this method is not called when the component within the frame is first displayed, see module:ct-component/ComponentLifecycleEvents#onOpen
.