macchina-io / macchina.io

macchina.io EDGE is a powerful C++ and JavaScript SDK for edge devices, multi-service IoT gateways and connected embedded systems.
https://macchina.io
GNU General Public License v3.0
516 stars 154 forks source link

setInterval is undefined? #69

Closed JoaoLeiria closed 6 years ago

JoaoLeiria commented 7 years ago

Hello everyone,

In a bundle, the first function that runs, has a setInterval in it. Pretty straightforward, I thought . But I'm getting a:

ReferenceError: setInterval is not defined

For what it's worth, for setTimeout, it's the same behaviour. How is this possible?

Best regards, João

obiltschnig commented 7 years ago

setInterval(), setTimeout() and setImmediate() are not available in all environments, only in those that have an event loop. For example, they are not available in JavaScript server pages or servlets.

JoaoLeiria commented 7 years ago

So @obiltschnig, I was running the code in a normal .js file. I believe the problem was that in the extensions.xml I had: <extension point="com.appinf.osp.js" script="start.js"/>

and not:

<extension point="com.appinf.osp.js" script="start.js" schedule="@start" />

I'm still testing the changes.

obiltschnig commented 7 years ago

@schedule is ignored for com.appinf.osp.js extension point. It's only valid for the com.appinf.osp.js.schedule extension point. In either case, setTimeout(), etc should work. Try creating a script in the Sandbox, then export the bundle from there.