| 1 |
/** |
| 2 |
* External dependencies |
| 3 |
*/ |
| 4 |
import refx from 'refx'; |
| 5 |
|
| 6 |
/** |
| 7 |
* Internal dependencies |
| 8 |
*/ |
| 9 |
//import effects from './effects'; |
| 10 |
|
| 11 |
const effects = { |
| 12 |
ENROLL_COURSE_X: ( action, store ) => { |
| 13 |
enrollCourse:( action, store ) => { |
| 14 |
const { dispatch } = store; |
| 15 |
|
| 16 |
//dispatch() |
| 17 |
}; |
| 18 |
}, |
| 19 |
}; |
| 20 |
|
| 21 |
/** |
| 22 |
* Applies the custom middlewares used specifically in the editor module. |
| 23 |
* |
| 24 |
* @param {Object} store Store Object. |
| 25 |
* |
| 26 |
* @return {Object} Update Store Object. |
| 27 |
*/ |
| 28 |
function applyMiddlewares( store ) { |
| 29 |
let enhancedDispatch = () => { |
| 30 |
throw new Error( |
| 31 |
'Dispatching while constructing your middleware is not allowed. ' + |
| 32 |
'Other middleware would not be applied to this dispatch.' |
| 33 |
); |
| 34 |
}; |
| 35 |
|
| 36 |
const middlewareAPI = { |
| 37 |
getState: store.getState, |
| 38 |
dispatch: ( ...args ) => enhancedDispatch( ...args ), |
| 39 |
}; |
| 40 |
|
| 41 |
enhancedDispatch = refx( effects )( middlewareAPI )( store.dispatch ); |
| 42 |
|
| 43 |
store.dispatch = enhancedDispatch; |
| 44 |
return store; |
| 45 |
} |
| 46 |
|
| 47 |
export default applyMiddlewares; |
| 48 |
|