Giter VIP home page Giter VIP logo

Comments (9)

staltz avatar staltz commented on June 8, 2024

Hmm, I understand this, but may I ask what is the root problem? What feature are you trying to achieve by wanting the periodic to keep emitting when the tab has changed?

from time.

stevenmathews avatar stevenmathews commented on June 8, 2024

Generating invoices from a pomodoro timer. Need the timer to continue while I work.

Nick asked me to open this issue but also recommended I use Time.animationFrames() which offers the functionality I need.

from time.

Frikki avatar Frikki commented on June 8, 2024

Doesn’t the events pick up and synchronize when you return to the tab?

from time.

stevenmathews avatar stevenmathews commented on June 8, 2024

@Frikki It pauses the time then resumes where it left off on refocus.

from time.

staltz avatar staltz commented on June 8, 2024

What if you don't use periodic() to track time, but just use periodic() to sample time? For instance with Date.now(). If you want a stopwatch, you can subtract from an initial timestamp.

from time.

stevenmathews avatar stevenmathews commented on June 8, 2024

What is the advantage of this approach over usingTime.animationFrames()? (wanting to learn not saying it's better).

from time.

Widdershin avatar Widdershin commented on June 8, 2024

They're comparable, but either way all it's not going to run in the background, since both of them are powered by requestAnimationFrame under the hood, and animations don't need to run in the background.

One option to consider, is that I just checked in Chrome and it seems like setImmediate still runs in the background, albeit slower, and I wouldn't be surprised if the polyfill hack using postMessage works as well.

I might consider powering periodic() and others from a setImmediate schedule to enable this. That additional flexibility in the design would also aid with implementing #29.

animationFrames and throttleAnimation would still be requestAnimationFrame powered and could be used to throttle the UI as needed, so that would be okay. We could just document how requestAnimationFrame works here.

from time.

Widdershin avatar Widdershin commented on June 8, 2024

Oh, and a use case as to why this is important: say you want to play a sound on a timer, it would not be great if it just didn't work at all because it was in a background tab. Much better to have it play 500ms later than not at all.

from time.

Widdershin avatar Widdershin commented on June 8, 2024

I started having a look and as I hoped the setImmediate polyfill runs in the background in Chrome and Firefox, so I can go ahead with this.

from time.

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.