Expanded migration notes to include decorators

This commit is contained in:
thepaperpilot 2023-04-19 22:19:45 -05:00
parent e771b33939
commit 0d84926900

View file

@ -130,6 +130,13 @@ Modifiers have renamed their `revert` property to `invert` to match the terms us
Lazy proxies now call the options function with the base object as the `this` argument and the first parameter. Features with `options` functions are expected to pass the base object as the `this` argument and first parameter as well. The `OptionsFunc` type has already been updated for this, so TS will complain if you skip this migration step. Lazy proxies now call the options function with the base object as the `this` argument and the first parameter. Features with `options` functions are expected to pass the base object as the `this` argument and first parameter as well. The `OptionsFunc` type has already been updated for this, so TS will complain if you skip this migration step.
You'll also want to add support for decorators. You'll want to add the new parameter `...decorators: GenericDecorator[]`, and then call their functions:
- Gather their persistent data _outside_ the layer proxy, like `const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {})`
- At the beginning of the layer proxy, call each `preConstruct` that exists, e.g. `decorators.forEach(d => d.preConstruct?.(feature))`
- At the end of the layer proxy, call each `postConstruct` that exists, e.g. `decorators.forEach(d => d.postConstruct?.(feature))`
- Gather props by generating them like `const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(achievement)), {})` and destructure it in the `GatherProps` function
## Fixing visibility changes ## Fixing visibility changes
Visibility properties now work with booleans, which has several implications. Visibility properties now work with booleans, which has several implications.