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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -