-
Notifications
You must be signed in to change notification settings - Fork 29
Add handler term from plenary description #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -313,6 +313,27 @@ To make something a first-class concept in a language specification, such that i | |||||
| #### References | ||||||
| - [Reification](https://en.wikipedia.org/wiki/Reification_(computer_science)) | ||||||
|
|
||||||
| ### Handler | ||||||
|
|
||||||
| #### Definition | ||||||
|
|
||||||
| A parameter value that is a JavaScript object with properties looked up lazily. It is used to configure behavior of a function. Methods on the options bag object should be invoked with the handler as the default value for `this`. It is expected that this parameter has specific well known properties in their structure. Handlers are expected to potentially be extended over time. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not unique to proxy if we consider DOM. I also dont think we should carve out that it only applies to proxies. future APIs may adopt this pattern
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, my suggestion doesn't indicate it's unique to proxy, just that it is used in Proxy, as an example. Where in the DOM is this pattern used?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Various places in DOM, easy to see for // never even returns a function to invoke
window.addEventListener('foo', {
UNIQUE_NAME: true,
get handleEvent() { console.log(this); }
});
window.dispatchEvent(new CustomEvent('foo'));
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow, i have never seen any code pass anything but a function in that position of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should add here that this is a specialized kind of options bag? |
||||||
|
|
||||||
| The definition here is a bit fuzzy as some parameters are objects but not options bags. | ||||||
|
|
||||||
| #### Example | ||||||
|
|
||||||
| ```js | ||||||
| const handler = { | ||||||
| getCount: 0, | ||||||
| get(target, key, receiver) { | ||||||
| const count = this.getCount++; | ||||||
| return count; | ||||||
| } | ||||||
| }; | ||||||
| new Proxy(obj, handler); | ||||||
| ``` | ||||||
|
|
||||||
| TEMPLATE | ||||||
| ### [NAME HERE] | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.