Explorar el Código

upgraded front and utils to be compatible with the new rxjs and redux-observable

Brandon Wong hace 6 años
padre
commit
0a26f1dde8
Se han modificado 4 ficheros con 14 adiciones y 5 borrados
  1. 1 1
      front/main.sh
  2. 4 1
      front/store.js
  3. 6 2
      utils/exampleEpic.js
  4. 3 1
      utils/exampleReducer.js

+ 1 - 1
front/main.sh

@@ -18,7 +18,7 @@ cd $foldername
 yarn add react-bootstrap \
          redux react-redux \
          react-router react-router-dom react-router-redux@next \
-         rxjs redux-observable
+         rxjs redux-observable rxjs-compat
 
 #TODO: integrate react-router routes https://medium.com/@notrab/getting-started-with-create-react-app-redux-react-router-redux-thunk-d6a19259f71f
 #TODO: integrate react-router-bootstrap https://github.com/react-bootstrap/react-router-bootstrap

+ 4 - 1
front/store.js

@@ -11,7 +11,8 @@ export const history = createHistory();
 
 const initialState = {},
     enhancers = [],
-    middleware = [routerMiddleware(history), createEpicMiddleware(rootEpic)];
+    epicMiddleware = createEpicMiddleware(),
+    middleware = [routerMiddleware(history), epicMiddleware];
 
 if( process.env.NODE_ENV === 'development' ) {
     const devToolsExtension = window.devToolsExtension;
@@ -32,5 +33,7 @@ const store = createStore(
     composedEnhancers,
 );
 
+epicMiddleware.run(rootEpic);
+
 export default store;
 

+ 6 - 2
utils/exampleEpic.js

@@ -1,9 +1,13 @@
 
-import 'rxjs';
+import { map } from 'rxjs/operators';
 
 export default function example(action$) {
     return action$.ofType('PING')
-        .mapTo({type: 'PONG'});
+    .pipe(
+        map(function () {
+            return {type: 'PONG'};
+        })
+    );
 };
 
 

+ 3 - 1
utils/exampleReducer.js

@@ -1,5 +1,7 @@
 
-const defaultState = Object.freeze({});
+const defaultState = Object.freeze({
+        
+    });
 
 export default function example(state = defaultState, action = {type:'NO-OP'}) {
     switch( action.type ) {