node.js - Just events in C++ -
while planning project, realized run better using evented programming. turns out event libraries focused on i/o stuff , don't give basic events nodejs' eventemitter
can, when object inherits it.
all looking enable ismple eventing in c++ code. let's assume code example:
class window : eventclass { private: nativewindow* _w; public: window() { // initialize window platform. _w = new nativewindow(); emit("init", _w); } void open() { // open window... emit("open", _w); } // ... }; int main() { window w(); w.on("init", [](nativewindow* w){ cout << "window initialized." << endl; }); w.on("open", [](nativewindow* w){ w->settitle("foo"); }); }
is there library enable such behaviour? ones saw focused on evented i/o, forgot provide raw eventing itself...
you can use nodejs addons allows use c++ libraries nodejs. refer link.
>> node-gyp configure build
this create addon, c++ snippet , can include in node js file using require(\path\to\addon)
Comments
Post a Comment