Implement something like the web's Service Workers

Having js run in the background could open up lots of possibilities for Fuse. I’d suggest having something like Service Workers on the web work in Fuse.

So we would have a FuseJS.BackgroundJS api, where we would register a “service worker” (idk what it would be called in Fuse):

var BackgroundJS = require('FuseJS/BackgroundJS');

BackgroundJS.register('/backgroundScript.js').then(function(registration) {
    // where registration is an object that references the registered script called 'backgroundScript.js' with a whole bunch of useful properties/methods

In our backgroundScript.js it would pretty much be the same as how Service Workers work:

self.addEventListener('install', function() {
    // when first installed

self.addEventListener('active', function() {
    // when first activated

self.addEventListener('fetch', function(evt) {
    // for every request
    // evt.request is a Request object

A Cache api would be exposed as well, etc and whatever is appropriate to run in the background for Fuse

As well the background script wouldn’t be able to export to the UI, it would run on a different thread etc.

And message passing would be implemented

and many more things

Here’s a good diagram of how Service Workers work:

Awesome Google IO presentation on it:

Yes, we already have this on the backlog. We have not started yet, but I will link the issue to this thread.

Sounds Awesome thanks