Skip to content
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

Add handler term from plenary description #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions terminology.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 Object

#### 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
A parameter value that is a JavaScript object with properties looked up lazily (used in `new Proxy`). 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various places in DOM, easy to see for .addEventListener

// never even returns a function to invoke
window.addEventListener('foo', {
  UNIQUE_NAME: true,
  get handleEvent() { console.log(this); }
});
window.dispatchEvent(new CustomEvent('foo'));

Copy link
Member

Choose a reason for hiding this comment

The 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 addEventListener.

Copy link
Contributor

Choose a reason for hiding this comment

The 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]

Expand Down