-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-config): add redux and saga configuration
- Loading branch information
Showing
8 changed files
with
2,946 additions
and
767 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,31 @@ | ||
import {buildStore} from "./store"; | ||
import firebase from "firebase"; | ||
import CONFIG from "@pipeline/app-config"; | ||
import 'firebase/analytics'; | ||
import 'firebase/auth'; | ||
import 'firebase/firestore'; | ||
import 'firebase/database'; | ||
|
||
export function bootstrap() { | ||
|
||
firebase.initializeApp({ | ||
apiKey: CONFIG.REACT_APP_FIREBASE_CONFIG_API_KEY, | ||
authDomain: CONFIG.REACT_APP_FIREBASE_CONFIG_AUTH_DOMAIN, | ||
databaseURL: CONFIG.REACT_APP_FIREBASE_CONFIG_DATABASE_URL, | ||
projectId: CONFIG.REACT_APP_FIREBASE_CONFIG_PROJECT_ID, | ||
storageBucket: CONFIG.REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET, | ||
messagingSenderId: CONFIG.REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID, | ||
appId: CONFIG.REACT_APP_FIREBASE_CONFIG_APP_ID, | ||
}); | ||
|
||
firebase.analytics(); | ||
|
||
const store = buildStore(); | ||
|
||
store.dispatch({type: 'test'}); | ||
// For sage test | ||
store.dispatch({type: 'ping'}); | ||
|
||
return store; | ||
|
||
} |
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,18 @@ | ||
import {configureStore} from '@reduxjs/toolkit'; | ||
import createSagaMiddleware from 'redux-saga'; | ||
import reducers from "./reducers"; | ||
import rootSaga from "./rootSaga"; | ||
|
||
const sagaMiddleware = createSagaMiddleware(); | ||
|
||
export default function () { | ||
const store = configureStore({ | ||
reducer: reducers, | ||
middleware: [ | ||
sagaMiddleware | ||
] | ||
}); | ||
|
||
sagaMiddleware.run(rootSaga) | ||
return store; | ||
} |
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,7 @@ | ||
|
||
|
||
import buildStore from "./buildStore"; | ||
|
||
export { | ||
buildStore | ||
} |
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,11 @@ | ||
import {Action, ReducersMapObject} from "@reduxjs/toolkit"; | ||
|
||
function testReducer(state = {}, action: Action) { | ||
return state; | ||
} | ||
|
||
const reducers: ReducersMapObject = { | ||
test: testReducer | ||
}; | ||
|
||
export default reducers; |
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,31 @@ | ||
import {Saga} from 'redux-saga'; | ||
import {all, call, put, spawn, takeEvery} from 'redux-saga/effects' | ||
|
||
function* testSaga() { | ||
yield put({type: 'pong'}); | ||
} | ||
|
||
function * testSagaRunner(){ | ||
yield takeEvery('ping', testSaga); | ||
} | ||
|
||
export default function* rootSaga() { | ||
const sagas: Saga[] = [ | ||
testSagaRunner | ||
]; | ||
|
||
yield all( | ||
sagas.map(saga => | ||
spawn(function* () { | ||
while (true) { | ||
try { | ||
yield call(saga); | ||
break; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
}), | ||
), | ||
); | ||
} |
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