Note: This package is no longer being maintained, migration to the lastest version of Stockroom is recommended.
Easily export your Unistore action to Web Workers for parallel computation/networking without impeding your UI.
General Process: Create Fx()
⇥ Build( Assign( Fx().toString ) )
⇥ Bind( 'Build' )
⇥ Profit.
const mapOperation = (a) => a * 25;
const operators = {
arrayOpMap : function(){
let worker_init_msg = "console.log('|UniOps| (%) arrayOpMap Worker: Initialized');";
let worker = uniops.buildOperator(...);
return worker;
},
}
uniops.buildOperator(
worker_init_msg,
uniops
.assignOperator
.array
.map
)
uniops.bindOperator.replace(worker, store, 'storeAttr');
Create modular, encapsulated, atomic functions to be passed to the worker. The function's logic should be appropriate for the chosen assignment profile. Otherwise there are no conventions or limitations to consider.
Create a unique factory method to build a worker instance preconfigured with the following parameters:
- Initialization message
- UniOps Assignment Profile
Choose one of the following profiles to assign to the worker based on the execution goal. The point of these profiles is to offload operations that expensive or inconvenient for the UI/UX to both speed up the processing of the operation and also unblock the UI until the worker has completed the operation. A profile is loaded with custom logic which the determines the 'flavor' of that type of operation. For example, the array map profile ingests a function, which actually controls the nature of the map operation.
- NETWORK: :
- XHR:
- GET: Execute an AJAX query.
- GQL:
- QUERY: Execute an Graph query.
- ARRAY: :
- Map: Map function across very large arrays.
- Filter: Filter function across very large arrays.
- Reduce: Reduce function across very large arrays.
- Union (Underscore): Computes the union of the passed-in arrays: the list of unique items, in order, that are present in one or more of the arrays.
- Intersection (Underscore): Computes the list of values that are the intersection of all the arrays. Each value in the result is present in each of the arrays.
- Difference (Underscore): Similar to without, but returns the values from array that are not present in the other arrays.
- Unique (Underscore): Produces a duplicate-free version of the array, using === to test object equality. In particular only the first occurrence of each value is kept. If you know in advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If you want to compute unique items based on a transformation, pass an iteratee function.
- Object (Underscore): Converts arrays into objects. Pass either a single list of [key, value] pairs, or a list of keys, and a list of values. Passing by pairs is the reverse of pairs. If duplicate keys exist, the last value wins.
- CANVAS: :
- Pixels: Convert a HTML5 Canvas element to Blob.
- FILE: :
- Upload: Upload a file.
- Blob: Convert uploaded file to blob.
Connect a built 'operator' (web worker w/ assigned profile) to a specified store attribute. Whenever the operator completes it's operation it will automatically update the store. There are two 'binding modes':
- Replace: Overwrites the store attribute.
- Modify: Partially updates the store attribute. (Coming Soon)
by Alex Reid