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

Add handler term from plenary description #87

wants to merge 2 commits into from

Conversation

bmeck
Copy link
Member

@bmeck bmeck commented Jul 22, 2020

No description provided.

@rkirsling
Copy link
Member

I think this would need to be more specific than just "handler". 🤔 I think the most common use of "handler (function)" is as a synonym for "(event) callback".

terminology.md Outdated Show resolved Hide resolved

#### 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.

Co-authored-by: Jordan Harband <ljharb@gmail.com>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants