worker-exchange3.0.0 • Public • Published
WorkerExchange is an extremely lightweight wrapper for HTML5 WebWorker and SharedWorker. It provides a consistent API across both type of workers, So you won't have to replace nothing to change between the types. You can even use the same js file as both Dedicated and Shared Worker, an example of it can be found in the Demo Folder.
It automatically declares
Exchange variable in Both Worker and Host scope.
It automatically creates an
Exchange instance in worker scope with the name
// Hostconst worker = Exchange;--- orconst worker = Exchange;worker;
Check out the Online Demo. (Check your browser console)
npm install --save worker-exchange
// Browserrequest(name: String, data: Mixed)onRequest(name: String, callback: Function)terminate() // <-- also disposes itdispose()static create(filePath): Exchangestatic createShared(filePath): Exchange}// WorkerforEach(callback: Function) /// <-- iterates over portsobserve(callback: Function): DisposableonRequest(name: String, callback: Function): DisposableonDidPortAdd(callback: Function): DisposableonDidPortClose(callback: Function): Disposabledispose()}: Disposable: Disposable
This project is licensed under the terms of MIT License. See the LICENSE file for more info.