The widget is a Dojo Dijit widget; therefore, when a widget instantiates, it goes through the full life cycle of a Dijit widget, such as constructor, postCreate, and startup. For more information, see http://dojotoolkit.org/documentation/tutorials/1.9/understanding_widgetbase/.
In addition to the Dojo Dijit life cycle functions, the widget has other callback functions that you can use:
Called each time the widget opens. When a widget instantiates, this method is called after startup.
Called when the widget is maximized. This method may never be called in some panels that do not have a maximize/minimize state.
Called when the widget is minimized. This method may never be called in some panels that do not have a maximize/minimize state.
Called when the widget closes.
Called when a user signs in to the portal or ArcGIS Online.
Called when a user signs out from the portal or ArcGIS Online.
Called when the widget's position (left, right, top, bottom, width, height) changes. The widget's position may be changed when the user changes the layout in the builder.
Called when the window resizes.
Called when the widget is normalized.
Called when the widget is active. A widget is active when users click it.
Called when the widget is not active. Other widgets are not active when users click a widget.
Called before the on-screen widget opens. By default, the widget is placed at the configured position, which can be overridden.
Returns the widgets' panel. For an off-panel widget, it is null.