-
Notifications
You must be signed in to change notification settings - Fork 15
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
Initial spec draft #28
Conversation
Enables biblio and spec linting
ome small grammar changes, reusing `AsyncContextSnapshot()`, simplifying `AsyncContextSnapshot()`, simplifying `AsyncContext.prototype.run()`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed some changes:
- Minor grammar updates
- Simplified
AsyncContextSnapshot()
to just return a reference to the current - Changed
AsyncContext.p.run()
to create a cloned mapping - Small updates to the spec steps
</ul> | ||
|
||
<emu-clause id="sec-asynccontext"> | ||
<h1>AsyncContext ( )</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about 2 extensions to the constructor:
- A
name
string - A
defaultValue
value
The name
string is intended to aid debugging in dev-tools. I imagine they might want to display the global context mapping, and it'd be more helpful if we could annotate that list in some way. This could be stored on the symbol's description.
The defaultValue
would be returned instead of undefined
whenever the context hasn't been run in this call stack. This is sometimes useful in React.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added name
as the first argument.
However, I'd find defaultValue
can be a foot gun as it may return the same reference to a single object and it may be mistakenly modified. A function returning a default value might be a better choice here.
spec.html
Outdated
@@ -366,13 +371,14 @@ <h1>The AsyncContext Constructor</h1> | |||
</ul> | |||
|
|||
<emu-clause id="sec-asynccontext"> | |||
<h1>AsyncContext ( )</h1> | |||
<h1>AsyncContext ( _name_ )</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we should bring this up in committee and add it to the spec afterwards. That with the defaultValue
API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed and opened an issue to track it: #29.
Is there a way to see a pretty-rendered version of the current spec? |
Please check out https://tc39.es/proposal-async-context/ for rendered version. |
This is the initial spec draft of the proposal. It follows the (tentative) idea of:
unhandledrejection
behavior #16:HostPromiseRejectionTracker
is called in the context at the time of the promise's rejection.