Arcturus
Manages state in worker threads through simple actions, reducers and selectors.
While using Redux I realised that your view and your state are decoupled enough that they could be placed in separate threads. Actions are scheduled and sent across to workers which like in Redux reduce the state before sending back the new state.
Status
This project is in Alpha stage and should really only be used by contributors.
Install
yarn add arcturus
or npm install arcturus
Usage
In your main thread
import { Arcturus } from 'arcturus';
const store = new Arcturus(['/dist/worker.js']);
store.establishConnection().then(() => {
store.subscribe(getState => {
console.log(getState());
})
store.dispatch({ type: 'increment' })
});
In a separate worker thread
import { createArcturusWorker, transformDomains } from 'arcturus';
const initialState = {
count: 1
}
function reducer (state = initialState, action) {
switch(action.type) {
case 'increment':
return { count: state.count + 1 };
default:
return state;
};
}
function selector (state) {
return state;
}
const domains = {
example: {
reducer,
selector
}
}
createArcturusWorker(...transformDomains(domains));
Examples
Currently we only have one example:
contributing
If you would like to contrubite please let me know or just createa PR this project is still in it's early stages.
For Direction please see the roadmap section below.
Roadmap to release
- Write tests
- Docs
- alpha
- publish to npm
- beta
- release
Future work