Lifecycle Hooks

Modules can use the pre-made Lifecycle Hooks in order to execute logic at specific times or to clean-up before being destroyed to prevent memory leaks.

These are all called as functions within the Module instance itself.


Like mounted, this is called as soon as the Module is instantiated. It will always be called before mounted and allows any bootstrapping of includes/other set-up. It is synchronous.


The most basic hook, this is called when, as the name suggests, the Module Element is mounted to the DOM. It is asynchronous, and you should return a Promise from it. Whilst resolving, a loader will be overlayed on to the Module Element. This is useful for fetching initial data.

If the returned Promise is rejected, the message given to reject will be shown to the User as feedback.