Repository navigation
Conversation
Start to an answer for https://github.com/nodejs/node/discussions/35870 Allows creating instances of EventTarget and Event at the native layer. With additional work, can be used to create classes that inherit from EventTarget and Event. Signed-off-by: James M Snell <jasnell@gmail.com>
|
Review requested:
|
|
I don't think it's possible to obtain a FunctionTemplate from an existing Function created in JS with the current V8 APIs..so IIUC the only way to inherit it would be through prototypal inheritance (maybe from C++)? |
Can someone explain what the issue with that is? :] |
|
There shouldn't be an issue really. At the c++ level it'll just mean that we have to create the objects separately then set the EventTarget or Event as the prototype of whatever other object you're creating. Slightly less efficient but it works (I've already verified that we can). |
|
/cc @gabrielschulhof |
The main drawbacks there are that a) you can’t make native classes inherit from them easily and b) you can’t instantiate these classes for other Fwiw, the code here LGTM, just not sure that we should add it until it’s needed? |
|
emmm, i don't know why we need it now🤔 |
|
Yep, this was largely just to show how in case @gabrielschulhof wanted to move forward on it. I've moved this to a draft. If we decide later to move forward on it I'll switch it back. |
Start to an answer for https://github.com/nodejs/node/discussions/35870
Allows creating instances of EventTarget and Event at the native layer. With additional work, can be used to create classes that inherit from EventTarget and Event.
Signed-off-by: James M Snell jasnell@gmail.com
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes