JoelOtter / kajero

Interactive JavaScript notebooks with clever graphing
Other
1.87k stars 110 forks source link

Resolve returned Promises in code blocks #44

Closed JoelOtter closed 8 years ago

JoelOtter commented 8 years ago

@xgrommx You should now be able to execute async stuff by returning a Promise. For timeout, for example...

return new Promise(function (resolve) {
    setTimeout(function() {
        resolve("This took three seconds.");
    }, 3000);
});

Or ES6, if your browser supports it (Chrome now does, seemingly):

return new Promise((resolve) =>
    setTimeout(() => resolve("This took three seconds."), 3000)
);

Have fun!