From c409f3afac60efae98d581ed54970569bab0a539 Mon Sep 17 00:00:00 2001 From: qwerty0981 Date: Fri, 2 Oct 2020 09:56:51 -0400 Subject: [PATCH] Add access to raw action type and raw action creator --- src/createReduxModule.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/createReduxModule.js b/src/createReduxModule.js index 71c724a..6b24010 100644 --- a/src/createReduxModule.js +++ b/src/createReduxModule.js @@ -29,7 +29,13 @@ const createReduxModule = (storeKey, initialState, reducers, store = getStore()) return [ () => useSelector(storeState => storeState[storeKey]), - mapKeys(reducers, type => payload => store.dispatch({ type: getQualifiedActionType(type), payload })), + mapKeys(reducers, type => { + const actionType = getQualifiedActionType(type) + const actionCreater = payload => store.dispatch({ type: actionType, payload }) + actionCreater.type = actionType + actionCreater.toAction = payload => { return { type: actionType, payload }} + return actionCreater + }), createVirtualStore(store, storeKey) ]; };