Added example using callbacks
This commit is contained in:
parent
6f90f78724
commit
0881081d5c
1 changed files with 14 additions and 0 deletions
14
src/v8test.erl
Normal file
14
src/v8test.erl
Normal file
|
@ -0,0 +1,14 @@
|
|||
-module(v8test).
|
||||
-export([run/0]).
|
||||
-include_lib("erlv8/include/erlv8.hrl").
|
||||
|
||||
run() ->
|
||||
application:start(erlv8),
|
||||
{ok, VM} = erlv8_vm:start(),
|
||||
Global = erlv8_vm:global(VM),
|
||||
Global:set_value("callback", erlv8_object:new([{"exec", fun (#erlv8_fun_invocation{}, []) -> myCallback() end}])),
|
||||
erlv8_vm:run(VM,"callback.exec();").
|
||||
|
||||
myCallback() ->
|
||||
io:format("Hello from myCallback!~n", []),
|
||||
ok.
|
Reference in a new issue