Component Lifecycle

Every Fluid component has a standard lifecycle, various points of which are signalled by firing of standard framework events. Every component which has a grade of fluid.component has these events attached, and the framework will fire them as the component reaches the appropriate lifecycle points. The events, in the expected order of firing for a component, are as follows:

Event Arguments Lifecycle Point
that {Component}
the component being constructed
Fired when component construction is complete - that is, all options have been merged for the component and all subcomponents (which were not marked with createOnEvent) have constructed.
that {Component}
the component being destroyed
Fired when the component is about to be destroyed. This will be a preliminary to beginning the destruction process for all its subcomponents.
that {Component}
the component which has been destroyed
Fired after the component and its children have been completely destroyed, and detached from any parent component.
Note: At this point you may only safely access plain data members of the component such as id and typeName. Do not attempt to invoke any methods, fire any events, or resolve any IoC references from listeners to this event.

Note that since JavaScript is a garbage-collected language, the component object reference and many of its members will hang around in memory during and after the destruction process, although it will as noted above be detached from its parent (via a call to delete) and similarly all subcomponent references will be recursively detached from their parents. The component author may schedule various actions to clean up any external resources (perhaps a jQuery widget, or a network connection) during the destruction process by adding listeners to the onDestroy event.

Every Fluid component is supplied with a standard method named destroy which is available after onCreate has fired. destroy takes no arguments and will initiate the destruction process for the component - onDestroy followed by afterDestroy.

Note: You can detect the lifecycle status of a component by means of the standard utility fluid.isDestroyed(component) - this will return true if the object reference represents a component which has been destroyed.