UNPKG

reactotron-redux

Version:
46 lines (45 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reactotronRedux = reactotronRedux; var _commandHandler = _interopRequireDefault(require("./commandHandler")); var _sendAction = _interopRequireDefault(require("./sendAction")); var _enhancer = _interopRequireDefault(require("./enhancer")); var _reducer = require("./reducer"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function reactotronRedux(pluginConfig = {}) { const mergedPluginConfig = { ...pluginConfig, restoreActionType: pluginConfig.restoreActionType || _reducer.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: (0, _commandHandler.default)(reactotron, mergedPluginConfig, onReduxStoreCreation), // All keys in this object will be attached to the main Reactotron instance // and available to be called directly. features: { createEnhancer: (0, _enhancer.default)(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: (0, _sendAction.default)(reactotron) } }; } return plugin; } //# sourceMappingURL=index.js.map