-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normative: Add
kind: "initializer"
for side effects
Many decorators will want to perform a side effect when instantiating a class, for example: - To select [[Set]] rather than [[DefineOwnProperty]] semantics for defining a field - To store the field in an entirely different place, neither an ordinary property or private field (e.g., MobX stores some fields in a Map) - To register the instance under construction in some way (e.g., from a class decorator). "Instance finishers" have been proposed for this purpose, but it's not clear when to run such a finisher. For many use cases (e.g., interacting with the DOM), an instance "starter" is just as good, due to run-to-completion semantics. This patch permits decorators to create elements of the form { kind: "initializer", placement: "own", initializer: fn } to be used purely for their side effect, with evaluation semantics and ordering identical to fields, and interspersed with them in evaluation order.
- Loading branch information
Showing
1 changed file
with
57 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters