Hooks

Hooks allow functionality to be inserted at a global level, across all controller instances. This provides a mechanism to extend or modify the behavior of components without altering their source code.

To use a hook, you define a function that gets called and attach it using hookOnGlobal(). This callback's arguments depend on the hook type, and is documented below. It's considered a global hook, which means it is attached to all event targets.

Component Definition

When any component is defined, a hook fires. This allows modification of the class as necessary. The hook is passed a reference to the custom element, not the controller.

component arguments:

Using this hook you can modify the component class so it will perform an action every time it is added to the DOM.

Bound Property Changes

Components can bind to controller properties and detect when those values change. Often they are updated when the component listens to attributes and properties, but the values could also change within the controller class.

When any bound property is changed, the set:PROP_NAME hook is fired. This indicates the property was set or updated. Also, this fires for scope property changes.

set:PROP_NAME arguments:

Similar to the named hook described above, all bound properties will also listen for `set:` (unnamed) hook invocations. Calling update() will trigger the `set:` hooks, either for one controller or all controllers.

set:PROP_NAME arguments: