diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-17 17:55:04 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:06:03 +0200 |
| commit | eb208a7e2fd020ab5d07d11cc6d52d1e3dcfcc7c (patch) | |
| tree | d2ec8a20408b7b2880e62feaa70fe95a78c484dd /src/reducers/states.js | |
| parent | 326b74fc39f63f47c71359276601ea93f7345dc6 (diff) | |
Add simulation mode framework
Includes object states in the store (by tick), charting, and progress bars.
Diffstat (limited to 'src/reducers/states.js')
| -rw-r--r-- | src/reducers/states.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/reducers/states.js b/src/reducers/states.js new file mode 100644 index 00000000..a9eb4ce8 --- /dev/null +++ b/src/reducers/states.js @@ -0,0 +1,33 @@ +import {combineReducers} from "redux"; +import {ADD_TO_STATES} from "../actions/states"; + +export const states = combineReducers({ + task: objectStates("task"), + room: objectStates("room"), + rack: objectStates("rack"), + machine: objectStates("machine"), +}); + +function objectStates(type) { + return (state = {}, action) => { + if (action.objectType !== type) { + return state; + } + + if (action.type === ADD_TO_STATES) { + return Object.assign( + {}, + state, + { + [action.tick]: Object.assign( + {}, + state[action.tick], + {[action.object.id]: action.object} + ) + } + ); + } + + return state; + }; +} |
