nxxm / js-bind

js::bind makes any C++ function, member function or lambda as a Javascript callback.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js::bind

js::bind makes any C++ function, member function or lambda as a Javascript callable callback for Emscripten.

Easy to use

It's header only. You can set-it-up in 0-time with : nxxm ., add this to .nxxm/deps

{
  "nxxm/js-bind" : { "@" : "v0.0.3" } 
}
  using namespace std;
  using namespace std::placeholders;
  using emscripten::val;

  auto clickme_btn = val::global("document").call<val>("getElementById", "clickme_btn"s);

  auto onclick = [](val event){ 
    std::cout << "hello world ! " << std::endl; 
  };

  clickme_btn.set("onclick", js::bind(onclick, _1));

License

Please give copyright notice for this project : Boost Software License.

Copyright (c) 2017 Damien Buhl alias daminetreg (damien.buhl@lecbna.org)

About

js::bind makes any C++ function, member function or lambda as a Javascript callback.

License:Boost Software License 1.0


Languages

Language:C++ 56.1%Language:HTML 38.1%Language:CMake 5.8%