1
0
Fork 0
freesewing/sites/dev/docs/reference/api/pattern/on/readme.mdx
Joost De Cock ab3204f9f1 chore: Port FreeSewing.dev to docusaurus
The replaces the NextJS site powering FreeSewing.dev with a Docusaurus
setup. It's part of my efforts to simplify FreeSewing's setup so we can
focus on our core value proposition.
2024-09-28 13:13:48 +02:00

40 lines
898 B
Text

---
title: Pattern.on()
---
The `Pattern.on()` method allows you to attach a function to one of the
pattern's [lifecycle hooks](/reference/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.
:::noteThis method is chainable as it returns the Pattern object:::
## Pattern.on() signature
```js
Pattern pattern.on(string hook, function method)
```
:::tip
Refer to [the Lifecycle hooks documentation](/reference/hooks/) for a list
of all available lifecycle hooks, as well as the signature of the function you
should pass it.
:::
## Pattern.on() example
```js
pattern.on('preRender', function(svg) {
svg.style += "svg { background: yellow;}";
})
```
Your pattern now has a yellow background.
:::tip
The [plugin guide](/guides/plugins/) contains more info on how you can use hooks
:::