2.0.0 • Published 2 years ago
ember-promise-worker v2.0.0
ember-promise-worker
Short description of the addon.
Compatibility
- Ember.js v3.24 or above
- Ember CLI v3.24 or above
- Node.js v12 or above
Installation
ember install ember-promise-worker
Usage
With ember-promise-worker, you can use web workers in your Ember project.
Develop your worker in <project_root>/workers/{name}/index.ts
and talk to them using the WorkersService.
Writing the worker code
workers/example/index.ts
import EPWorker from 'ember-promise-worker/objects/EPWorker';
const worker = new EPWorker();
worker.register((message) => {
// Can also be async ^
if (message.action === "DESERIALIZE") {
// do something
return result;
} else {
throw new Error("Unknown action")
}
})
Talking to the worker
import WorkersService, { EPWorkerMessage } from "ember-promise-worker/services/workers";
// 1. Inject the 'workers' service
const WORKER_NAME = "example";
const action = "DESERIALIZE"; // string
const args = { myData: 1 } // any
// transferables?: Transferable[]
const message: EPWorkerMessage = { action, args, transferables }
const response = await this.workers.workerMessage(WORKER_NAME, message)
Contributing
See the Contributing guide for details.
License
This project is licensed under the MIT License.
1.3.4
3 years ago
2.0.0-beta.1
2 years ago
2.0.0
2 years ago
1.3.3
3 years ago
1.3.2
3 years ago
1.3.1
3 years ago
1.3.0
3 years ago
1.0.0-beta.2
3 years ago
1.0.0-beta.1
3 years ago
1.1.0-beta.1
3 years ago
1.2.0-beta.1
3 years ago
1.2.0-beta.2
3 years ago
0.1.0-beta.5
3 years ago
0.1.0-beta.4
3 years ago
0.1.0-beta.3
3 years ago
0.1.0-beta.2
3 years ago
0.1.0-beta.1
3 years ago
0.0.1-beta.2
3 years ago
0.0.1-beta.1
3 years ago