2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
title: Hooks
|
|
|
|
order: 60
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
A **hook** is a lifecycle event. The available hooks are:
|
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
- [preRender](/reference/hooks/prerender/): Called at the start of [`Pattern.render()`](/reference/api/pattern#render)
|
|
|
|
- [postRender](/reference/hooks/postrender/): Called at the end of [`Pattern.render()`](/reference/api/pattern#render)
|
|
|
|
- [insertText](/reference/hooks/inserttext/): Called when inserting text
|
|
|
|
- [preDraft](/reference/hooks/predraft/): Called at the start of [`Pattern.draft()`](/reference/api/pattern#draft)
|
|
|
|
- [postDraft](/reference/hooks/postdraft/): Called at the end of [`Pattern.draft()`](/reference/api/pattern#draft)
|
|
|
|
- [preSample](/reference/hooks/presample/): Called at the start of [`Pattern.sample()`](/reference/api/pattern#sample)
|
|
|
|
- [postSample](/reference/hooks/postsample/): Called at the end of [`Pattern.sample()`](/reference/api/pattern#sample)
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
You can register a method for a hook. When the hook is triggered, your method will be
|
|
|
|
called. It will receive two parameters:
|
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
- An object relevant to the hook. See the [hooks API reference](/reference/hooks/) for details.
|
|
|
|
- Data passed when the hook was registered (optional)
|