Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
fix: Add a new API for how to register the redux store to fix an issu…
Browse files Browse the repository at this point in the history
…e with dispatching from reactotron into the middleware.
  • Loading branch information
rmevans9 committed Aug 25, 2019
1 parent 00de295 commit bdd8702
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/enhancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function createEnhancer(
pluginConfig: PluginConfig,
handleStoreCreation: () => void
) {
return () => createStore => (reducer, ...args) => {
return (skipSettingStore = false) => createStore => (reducer, ...args) => {
const originalStore = createStore(
reactotronReducer(reducer, pluginConfig.restoreActionType),
...args
Expand All @@ -18,9 +18,11 @@ export default function createEnhancer(
...originalStore,
dispatch: createCustomDispatch(reactotron, originalStore, pluginConfig),
}
reactotron.reduxStore = store

handleStoreCreation()
if (!skipSettingStore) {
reactotron.reduxStore = store
handleStoreCreation()
}

return store
}
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function reactotronRedux(pluginConfig: PluginConfig = {}) {
onCommand: createCommandHander(reactotron, mergedPluginConfig, onReduxStoreCreation),
features: {
createEnhancer: createEnhancer(reactotron, mergedPluginConfig, handleStoreCreation),
setReduxStore: store => {
reactotron.reduxStore = store
handleStoreCreation()
},
reportReduxAction: createSendAction(reactotron),
},
}
Expand All @@ -44,6 +48,11 @@ declare module "reactotron-core-client" {
/**
* Enhancer creator
*/
createEnhancer?: () => StoreEnhancer
createEnhancer?: (skipSettingStore?: boolean) => StoreEnhancer

/**
* Store setter
*/
setReduxStore?: (store: any) => void
}
}

0 comments on commit bdd8702

Please sign in to comment.