Comments (3)
Hi @sdford,
the implementation of setInterval()/setTimeout()
is very similar. It is handled by the worker-timers-worker package in case you want to review it yourself: https://github.com/chrisguttandin/worker-timers-worker/blob/master/src/helpers/timer.ts. setInterval()
and setTimeout()
both use the native setTimeout()
function internally.
I don't know what really happens when a laptop is pretending to sleep. But I would be surprised if it could be woken up by some JavaScript code. If the numbers in your example code are the actual values you used to test the functionality, it could be the case that setInterval()
keeps working because the laptop never ever falls asleep when it has to do something every 2 seconds. But if you schedule a timeout to fire in 3 minutes it might fall asleep before the timeout is about to fire.
That's of course just a rough guess. Can you please try to run both functions with the same delay?
from worker-timers.
Thanks for the quick response. I believe you're right; at least the explanation sounds believable.
I have increased the timeout to 300000 milliseconds (5 mins), and now observe the same behavior (where setInterval()
also does not trigger while the laptop is "asleep", similar to setTimeout
).
It seems that setInterval
is required (with a small enough time period) to accomplish the results that I would like.
from worker-timers.
Hi @sdford,
I'm sorry that worker-timers is not working (or at least is not working as expected) for your use case. I haven't tested that, but I could imagine a push notification may be the only thing which is capable of waking up a laptop. That's just a guess and there is a good chance that it might not work as well. But if it does you could "catch" the notification with a ServiceWorker and handle it as you like without showing anything to the user.
I'm closing this issue now as worker-timers can't be modified to support this use case.
from worker-timers.
Related Issues (20)
- An in-range update of worker-timers-worker is breaking the build 🚨 HOT 1
- An in-range update of worker-timers-broker is breaking the build 🚨 HOT 1
- An in-range update of rollup is breaking the build 🚨 HOT 1
- An in-range update of karma is breaking the build 🚨 HOT 2
- An in-range update of worker-timers-broker is breaking the build 🚨 HOT 1
- An in-range update of rollup is breaking the build 🚨 HOT 2
- worker-timer is failing in IE11 HOT 3
- workerTimers.setInterval() not working in ipad and iphone devices in background HOT 11
- What's the accuracy? HOT 3
- There is no interval scheduled with the given id HOT 2
- Can't mock any method by jasmine spyOn HOT 5
- There is no interval scheduled with the given id
- Worker in separate file HOT 1
- Not working when using esbuild HOT 4
- CDN link for browser. HOT 5
- Only minified source code included in this repo HOT 2
- There is no timeout scheduled with the given id "386". HOT 10
- Add support for Chrome & FireFox extensions HOT 3
- 安装最新版本,子依赖fast-unique-numbers会安装8.0.10版本,导致node@14不可用 HOT 1
- setTimeout(f) isn't working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from worker-timers.