oliviertassinari / serviceworker-webpack-plugin

Simplifies creation of a service worker to serve your webpack bundles. :recycle:
https://oliviertassinari.github.io/serviceworker-webpack-plugin/
MIT License
458 stars 76 forks source link

How to start demo app in doc/ #62

Closed yiakwy closed 6 years ago

yiakwy commented 6 years ago

Hi there is no package.json file nor execution scripts in the root of docs. Could you explain me that how to use it to start the application

devCrossNet commented 6 years ago

hey, clone the repo and install the dependencies, after everything is installed run the script npm run docs:development. That worked for me.

yiakwy commented 6 years ago

@devCrossNet Thanks. I installed the dependancies globally from the root of the project. That works for me now. Thank you again.

I will study it carefully. Basically I understand how it works. Now I want to integrate Service Worker as an independant computation and query loop. Could you give me some advice on it?

Since it is background thread, it has some computation power,

(1) The programme has a rendering loop rendering geometries. Instead of executing sequence by sequence, I want the workers do that in advance and wait for main page js programme to query for

(2) Every geometry has an unique Id generated by front end app. If I query for it, the user UI generated by React will become slow. Instead of executing sequence by seqence, I want the main page send a query to background thread (service worker), do some searching algorithms, and notify client page main thread when it is ready.

(3) If possible I want to implement a publisher and subscriber pattern using an observer. But it seems that only one thread for one domain is allowed. How should organize my programmes?

here is the hierarchy of my codes

backend
frontend
   src/
        module1
        UICom/
        common/
        module2
        module3/
        ....
        workers/
               router.js
               storage.js
               utils/
                     messager.js

Thank you very much!

devCrossNet commented 6 years ago

Hey, are you talking about web-worker instead of service-worker? The purpose of a service worker is to serve as a gateway to the internet e.g. cache assets and get it from the cache instead of the network if your device is offline.

have a look at this doc: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers

yiakwy commented 6 years ago

Oh I get it. I am talking about a worker (maybe web worker, I will check it).

I am trying to use service worker (a proxy thread) because I just got ideas half a year ago from google when it introduced PWA / AMP caching into developers and companies. But I don't think they are different. Any live objects in memory can be dumped to json format and recovered from json (serialization). If there is a loop, it might be able to work as a computation engine.

Is it possible? Is there a successful story?