Pattern.on()

The Pattern.on() method allows you to attach a function to one of the pattern’s lifecycle hooks. It takes the lifecycle hook’s name as the first argument and the function as the second. This method will then be triggered by the lifecycle hook.

NOTE
This method is chainable as it returns the Pattern object

Pattern.on() signature

Javascript
Pattern pattern.on(string hook, function method)
TIP

Refer to the Lifecycle hooks documentation for a list of all available lifecycle hooks, as well as the signature of the function you should pass it.

Pattern.on() example

Javascript
pattern.on('preRender', function(svg
) {
  svg.style += "svg { background: yellow;}";
})

Your pattern now has a yellow background.

TIP

The plugin guide contains more info on how you can use hooks