-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Did some learning on how redux store works from redux.js.org 2. Implemented the initial barebones required for redux state, middleware, reducers and store 3. Given the provider component to the main index.js file 4. Checked the working condition of the initial redux state from redux-devtools
- Loading branch information
1 parent
08d2c2b
commit 283f04d
Showing
9 changed files
with
17,681 additions
and
174 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* helps to create the combined reducers instance for the redux store | ||
**/ | ||
|
||
/* node module imports */ | ||
import { combineReducers } from "redux"; | ||
|
||
/* app imports */ | ||
import cardsReducer from "./cards/index.js"; | ||
import gameStateReducer from "./game-state/index.js"; | ||
|
||
export const reducersCentral = () => { | ||
return combineReducers({ | ||
cards: cardsReducer, | ||
gameIsComplete: gameStateReducer | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let initialState = []; | ||
|
||
export default function cardsReducer(state = initialState, action) { | ||
return state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let initialState = false; | ||
|
||
export default function gameStateReducer(state = initialState, action) { | ||
return state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* main entry file for the application's redux store | ||
**/ | ||
|
||
/* node modules import */ | ||
import { createStore } from "redux"; | ||
|
||
/* app imports */ | ||
import { reducersCentral } from "./all-reducers.js"; | ||
import { appMiddlewareCentral } from "./middleware/index.js"; | ||
|
||
export const appReduxStore = () => { | ||
return createStore( | ||
reducersCentral(), | ||
appMiddlewareCentral() | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* this gives the ability to use middleware along with the redux dev tools instance to track state | ||
* changes in the app | ||
**/ | ||
|
||
/* node modules imports */ | ||
import { applyMiddleware } from "redux"; | ||
import { composeWithDevTools } from '@redux-devtools/extension'; | ||
|
||
/* app imports */ | ||
import { samuraiMiddleware } from "./samurai-api-fetch/index.js"; | ||
|
||
export const appMiddlewareCentral = () => { | ||
return composeWithDevTools( | ||
applyMiddleware(samuraiMiddleware) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const samuraiMiddleware = (storeApi) => { | ||
return (next) => { | ||
return (action) => { | ||
next(action); | ||
return; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
/* node modules imports */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { Provider } from "react-redux"; | ||
|
||
/* app imports */ | ||
import { App } from './App'; | ||
import { appReduxStore } from "./app-redux-store/index.js"; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
root.render(<App />); | ||
root.render( | ||
<Provider store={appReduxStore()}> | ||
<App /> | ||
</Provider> | ||
); |