UNPKG

reactotron-redux

Version:
42 lines (41 loc) 1.47 kB
"use strict"; import createCommandHander from "./commandHandler.js"; import createSendAction from "./sendAction.js"; import createEnhancer from "./enhancer.js"; import { DEFAULT_REPLACER_TYPE } from "./reducer.js"; function reactotronRedux(pluginConfig = {}) { const mergedPluginConfig = { ...pluginConfig, restoreActionType: pluginConfig.restoreActionType || DEFAULT_REPLACER_TYPE }; const storeCreationHandlers = []; const onReduxStoreCreation = func => { storeCreationHandlers.push(func); }; const handleStoreCreation = () => { storeCreationHandlers.forEach(func => { func(); }); }; function plugin(reactotron) { return { // Fires when we receive a command from the Reactotron app. onCommand: createCommandHander(reactotron, mergedPluginConfig, onReduxStoreCreation), // All keys in this object will be attached to the main Reactotron instance // and available to be called directly. features: { createEnhancer: createEnhancer(reactotron, mergedPluginConfig, handleStoreCreation), setReduxStore: store => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore shhhhhh -- this is a private API reactotron.reduxStore = store; handleStoreCreation(); }, reportReduxAction: createSendAction(reactotron) } }; } return plugin; } export { reactotronRedux }; //# sourceMappingURL=index.js.map