ServiceWorker task scheduler
This is a proof of concept of a task scheduler inside a ServiceWorker.
The Service Worker has a non-blocking infinite loop (using
setInterval) constantly checking in a task
Set whether the due date arrives and runs the task.
When a user sends a
task message to the service worker:
- It adds the task to a list of pending tasks
- Then the worker compares the scheduled date of the task against a
Dateobject with the actual date
- If dates match, the task is run and a notification is shown
- The task is added to a
Setof done tasks (to keep track of already done tasks)
$ git clone https://github.com/cgrs/sw-task-scheduler.git $ cd sw-task-scheduler $ npm install $ npm start