Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

Run dynamic JavaScript code


I want to run JavaScript code stored in a file at runtime. Something like this:"code.js");

What I did find so far is the "run_if_exists" method in
But I cannot get a reference to the mjs object either in "main.c" neither in "init.js"

Can somebody please tell me how to achieve this?


  • quaxquax Europe

    Found a solution:
    mjs_exec_file(mgos_mjs_get_global(), "code.js", NULL);

    But how can I destroy the previous mjs instance when calling this over and over again? Especially when using Timers. They keep on running.

Sign In or Register to comment.