forked from open-source-labs/Reactime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmasterState.js
40 lines (35 loc) · 991 Bytes
/
masterState.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'core-js';
/* eslint-disable no-plusplus */
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
const componentActionsRecord = {};
let index = 0;
// module.exports = {
export default {
saveNew: (state, component) => {
componentActionsRecord[index] = { state, component };
index++;
return index - 1;
},
getRecordByIndex: inputIndex => componentActionsRecord[inputIndex],
getComponentByIndex: inputIndex => (componentActionsRecord[inputIndex]
? componentActionsRecord[inputIndex].component
: undefined),
};
/* const masterState = [];
const hooksComponentsActions = {};
module.exports = {
saveState: state => {
for (const key in state) {
masterState.push(state[key]);
}
return masterState;
},
returnState: () => masterState,
saveHooksComponent: stateAndAction => {
for (const elementName in stateAndAction) {
hooksComponentsActions[elementName] = stateAndAction[elementName];
}
},
};
*/