ember-multithread (Still WIP)
Dead-simple multi-threading support for Ember.js applications.
Installation
ember-multithread
is an Ember-CLI addon. You can install it via:
ember install ember-multithread
Usage
WorkerProperty
Basic usage of You can create WorkerProperty
in your controllers, routes or components.
import Ember from 'ember';
import {worker} from 'ember-multithread';
export default Ember.Controller.extend({
calculatePi: worker(function(iteration) {
let pi = 0;
let n = 1;
for (let i = 0; i <= iteration; i++) {
pi = pi + (4 / n) - (4 / (n + 2));
n = n + 4;
}
return pi;
}),
actions: {
calculate() {
this.get('calculatePi').perform(500000000).then(result=> {
console.log(result);
});
}
}
});
Set properties in your Ember app
This may cause race conditions if there are multiple works running simultaneously in one controller.
TODO
ember-concurrency
Synergy with TODO
map()
and reduce()
Multi-threaded TODO
Restriction
TODO
Special Thanks
Thanks ember-concurrency and parallel.js for the inspiration.