2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: preDraft
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:43:00 +02:00
|
|
|
The `preDraft` lifecycle hook runs just before your pattern is drafted.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:43:00 +02:00
|
|
|
## Signature
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:43:00 +02:00
|
|
|
```js
|
|
|
|
null hook(Pattern pattern)
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:43:00 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:43:00 +02:00
|
|
|
```js
|
|
|
|
pattern.on('preDraft', pattern => {
|
|
|
|
// Mutate the pattern object here
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
2024-02-17 16:14:14 +01:00
|
|
|
The `preDraft` hook fires once for all the sets in the pattern.
|
|
|
|
While typically, there is only one set, there might be more.
|
|
|
|
In that case, the [`preSetDraft` lifecycle hook](/reference/hooks/presetdraft) is
|
|
|
|
the per-set equivalent of this hook.
|