@livechat/widget-core.
Component lifecycle
Mount
During the mounting phase of the component, the Chat Widget is fully initialized. Before the mount, the widget instance does not exist and does not have access to any provided data. The mount is the first moment when an instance of the widget is created and receives the first set of data.- Use the obtained data as parameters for widget initialization
- Create a Chat Widget JS API instance as presented in the code snippet.
- Register the provided event handlers for the corresponding events.
- To update the related data, notify the reactive data interface that the widget has been initialized.
Update
This phase allows for updating provided data or callbacks by changing their value or reference. To do so, the component internally observes such changes and translates them to appropriate imperative mutations via JS API method calls.- If properties were updated, then call the corresponding setter methods from JS API.
- If properties that require a full reload were updated, then reinitialize the widget with new properties.
- If event handlers were updated, then unregister the previous one and register a new one for the corresponding event.
Unmount
This phase results in a complete Chat Widget cleanup but allows for a proper Mount phase once again.- Unregister all registered callbacks.
-
Call the
destroymethod from JS API. - To clear the related data, notify the reactive data interface that the widget has been destroyed.