-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
According to @yosuke-furukawa san, something like python's __call__ method (that's for objects, and in this case for classes) will be useful if introduced.
Many nodejs modules (ex. https://github.com/flatiron/nock) are providing a kind of tricky API, that is a function object which returns new instances every time it's called. They are alternative style of class and JSX doesn't have a means of getting access to these functions.
I suggest JSX introduce a special method called __new__, which enables users to call classes directly as if it is an object.
var nock = require('nock');
// creating a nock object via function call, not `new` operation
var couchdb = nock('http://myapp.iriscouch.com');// A class that has a `__new__` method can called as if an object
native class nock {
static function __new__ (url : string) : scope;
} = "require('nock')";
class _Main {
static function main (args : string[]) : void {
var scope = nock();
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels