Caplin Trader 4.8.0

Interface: module:caplin/component/ComponentLifecycleEvents


The 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.




Invoked when the frame becomes the active or focused frame within the page.


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().



Invoked when the frame ceases to be the active or focused frame within the page.


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.


Invoked when the frame has been maximized.


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 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.

Name Type Description
nWidth int The width of the frame, in pixels.
nHeight int The height of the frame, in pixels.
  • 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.
Name Type Description
nWidth int The new width of the frame, in pixels.
nHeight int The new height of the frame, in pixels.


Invoked when the frame has been restored from a minimized or maximized state.


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 by onHide().

N.b. this method is not called when the component within the frame is first displayed, see module:caplin/component/ComponentLifecycleEvents#onOpen.