File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // import action types
2+ import { RECORD_COMMAND , REPLAY_COMMANDS } from "./actions/actiondomain" ;
3+
4+ // Default state for general
5+ export const ACTION_DOMAIN_DEFAULT_STATE = {
6+
7+ } ;
8+
9+ const recordCommand = ( state , { kernel, command } ) => {
10+ const newState = { ...state } ;
11+ if ( ! newState [ kernel ] ) {
12+ newState [ kernel ] = [ ]
13+ }
14+ newState [ kernel ] . push ( command )
15+ return newState ;
16+ }
17+
18+ const replayCommands = ( state , { kernel } ) => {
19+ console . log ( "TODO, REPLAY COMMANDS" )
20+ }
21+
22+ // reducer
23+ const reducer = ( state = ACTION_DOMAIN_DEFAULT_STATE , action ) => {
24+ switch ( action . type ) {
25+ case RECORD_COMMAND :
26+ return recordCommand ( state , action . payload )
27+ case REPLAY_COMMANDS :
28+ return replayCommands ( state , action . payload )
29+ default :
30+ return state
31+ }
32+ }
33+
34+ const redux = require ( "redux" ) ;
35+ const createStore = redux . createStore ;
36+ const store = createStore ( reducer ) ;
37+
38+ export { store }
Original file line number Diff line number Diff line change 1+ // Action Types
2+ export const RECORD_COMMAND = 'RECORD_COMMAND' ;
3+ export const REPLAY_COMMANDS = 'REPLAY_COMMANDS' ;
4+
5+ // Actions
6+ export const recordCommand = ( kernelID , command ) => ( {
7+ type : RECORD_COMMAND ,
8+ payload : {
9+ kernel : kernelID ,
10+ command : command
11+ }
12+ } ) ;
13+
14+ export const replayCommands = ( kernelID ) => ( {
15+ type : REPLAY_COMMANDS ,
16+ payload : {
17+ kernel : kernelID
18+ }
19+ } )
You can’t perform that action at this time.
0 commit comments