I'm using embind to wrap a JS library in C++. The library uses callbacks 
such as:
>
> object.on('connect', function() {
>   console.log('connected');
> });

How can I use a C++ function as callback?

Ideally, I'd like to do something like:

> val object = val::global("object");
> object.call<void>("on", std::string("connect"), []() {
>   std::cout << "connected" << std::endl;
> });

which, unfortunately, throws "Uncaught BindingError: parameter 2 has 
unknown type" with a mangled lambda type name.

Chad recently posted something related to C++ callbacks 
<http://chadaustin.me/2014/06/emscripten-callbacks-and-c11-lambdas/> but 
doesn't talk about this specific issue. If that's unsupported, what would 
embind need to support C++ callbacks?

Also, what's the workaround?

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to