-
Notifications
You must be signed in to change notification settings - Fork 168
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
TAG issue: Constructibility & De-sugaring of static methods #250
Comments
The last example allows much more fluent coding. The "Composing New Nodes" section of http://htmlpreview.github.io/?https://github.com/pendragon-andyh/tony.js/blob/master/examples/example-api.html takes the same approach with the AudioContext's factory methods - and also allows AudioParam values to be set. It also allows connect/disconnect/start/stop to be chained - to allow much more concise code. |
Next step: discuss with TAG, include in written response to the TAG issues, including this one. |
@cwilso has there been any discussion with TAG? We need to address this in order to get the spec into V1 shape. Please let the group know if you are still on this, or if the chairs should find another way to resolve. |
TPAC: De-sugar all concrete context-created node types by adding constructors with context as initial parameter, and create...() arguments as subsequent parameters.
|
Currently I am hesitating to do this until #308 can be merged due to the mess caused by the base interface name change. |
This is now in progress via #662 |
The following issue was raised by the W3C TAG as part of their review of the Web Audio API
Constructibility & De-sugaring of static methods
The current API defines 26 interfaces:
Of these, only two are marked constructible:
Most of the types represented by the non-constructable interfaces are visible in the API through normal use. For instance, to get a
PannerNode
instance a developer currently uses:Where
context
is an instance ofAudioContext
(or one of its subclasses). Prickly questions arise from this arrangement:context
are desirable shortcuts for wiring up the context of aNode
instance to thecontext
against which it runs, how does that context get set in a way that would allow pure JS objects to describe it?create*()
methods but no factory (e.g.:createElement("tagname")
)Adding constructors and context-setting methods (or constructor params) for most of the interfaces that lack them would answer #'s 1 and 2 and largely obviate 4. E.g.:
Either constructor style allows these
AudioNode
types to conceptually be modeled more cleanly as JS objects which could self-host.Of course, this requires answering the follow-on questions "what happens if the context is invalid, changes, or is never set?", but those are reasonable to ask and their answers don't need to be complicated (certainly not for v1).
An alternative design might locate the constructors on the context directly, but this seems to create as many problems as it solves.
Using the constructor style from the last variant, we can re-work one of the examples from Section 7:
to:
The text was updated successfully, but these errors were encountered: