Open nex3 opened 7 years ago
Similar to #24779 ?
This feature would be extremely useful. I'm not even sure if it's possible to create a workaround until this feature is implemented. Are there any plans for this?
Also, to achieve the requested functionality, it might not be necessary to modify the prototype of a class at all. Perhaps all methods not marked as external could be interpreted as non-JS methods?
There's currently no way for (non-SDK) Dart code to modify a class's prototype, which makes it difficult to expose Dart-like APIs for JS classes without resorting to inefficient wrapper objects. For example, we might want to expose Node.js's
net.Server.close([callback])
method so it exposes a more Dart-y future API:dart:html
does this frequently, but the inability to do it outside the SDK means that user-defined JS wrappers can't provide APIs that are as usable as those in the SDK.I propose we add an
@OnPrototype([String jsName])
annotation to thejs
package that explicitly indicates that a method should be added to the class's prototype. For example: