Conversation
|
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". |
|
|
||
| #### 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'));There was a problem hiding this comment.
wow, i have never seen any code pass anything but a function in that position of addEventListener.
Co-authored-by: Jordan Harband <[email protected]>
|
|
||
| #### 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. |
There was a problem hiding this comment.
Maybe we should add here that this is a specialized kind of options bag?
No description provided.