Code Monkey home page Code Monkey logo

Comments (3)

gfwilliams avatar gfwilliams commented on June 21, 2024

This should really be a bug report for in Espruino.

But: While I can see it would be useful, I'm not sure:

setInterval(foo, 60000, { execNow : true });

is really any more obvious than:

setInterval(foo, 60000);
foo();

or:

setInterval(foo, 60000);
setTimeout(foo, 1);

I just don't think it's a good idea - mainly because setInterval is something that's used all over the place and is basically a standard (web browsers, node, etc) and changing the behaviour would be bad news.

from espruinodocs.

kimbauters avatar kimbauters commented on June 21, 2024

Should be in Espruino, again, my apologies.

I leave this one up to you. Another option would be to introduce a new function that just wraps the setInterval and the direct execution in one. I have used this construct a lot so far, so I would argue that it is a fairly typical use case.

from espruinodocs.

gfwilliams avatar gfwilliams commented on June 21, 2024

Sorry - I'm going to close this one. Nobody else has had problems with the old implementation, and you could easily just write the following at the top of your code:

function setIntervalNow(a,b,c) {
  a();
  return setInterval(a,b,c);
}

from espruinodocs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.