1 |
- {"ast":null,"code":"/** A function that accepts a potential \"extra argument\" value to be injected later,\r\n * and returns an instance of the thunk middleware that uses that value\r\n */\nfunction createThunkMiddleware(extraArgument) {\n // Standard Redux middleware definition pattern:\n // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware\n var middleware = function middleware(_ref) {\n var dispatch = _ref.dispatch,\n getState = _ref.getState;\n return function (next) {\n return function (action) {\n // The thunk middleware looks for any functions that were passed to `store.dispatch`.\n // If this \"action\" is really a function, call it and return the result.\n if (typeof action === 'function') {\n // Inject the store's `dispatch` and `getState` methods, as well as any \"extra arg\"\n return action(dispatch, getState, extraArgument);\n } // Otherwise, pass the action down the middleware chain as usual\n\n\n return next(action);\n };\n };\n };\n\n return middleware;\n}\n\nvar thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version\n// with whatever \"extra arg\" they want to inject into their thunks\n\nthunk.withExtraArgument = createThunkMiddleware;\nexport default thunk;","map":{"version":3,"sources":["/home/ilya/projects/NIX/homework/react-store/node_modules/redux-thunk/es/index.js"],"names":["createThunkMiddleware","extraArgument","middleware","_ref","dispatch","getState","next","action","thunk","withExtraArgument"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,qBAAT,CAA+BC,aAA/B,EAA8C;AAC5C;AACA;AACA,MAAIC,UAAU,GAAG,SAASA,UAAT,CAAoBC,IAApB,EAA0B;AACzC,QAAIC,QAAQ,GAAGD,IAAI,CAACC,QAApB;AAAA,QACIC,QAAQ,GAAGF,IAAI,CAACE,QADpB;AAEA,WAAO,UAAUC,IAAV,EAAgB;AACrB,aAAO,UAAUC,MAAV,EAAkB;AACvB;AACA;AACA,YAAI,OAAOA,MAAP,KAAkB,UAAtB,EAAkC;AAChC;AACA,iBAAOA,MAAM,CAACH,QAAD,EAAWC,QAAX,EAAqBJ,aAArB,CAAb;AACD,SANsB,CAMrB;;;AAGF,eAAOK,IAAI,CAACC,MAAD,CAAX;AACD,OAVD;AAWD,KAZD;AAaD,GAhBD;;AAkBA,SAAOL,UAAP;AACD;;AAED,IAAIM,KAAK,GAAGR,qBAAqB,EAAjC,C,CAAqC;AACrC;;AAEAQ,KAAK,CAACC,iBAAN,GAA0BT,qBAA1B;AACA,eAAeQ,KAAf","sourcesContent":["/** A function that accepts a potential \"extra argument\" value to be injected later,\r\n * and returns an instance of the thunk middleware that uses that value\r\n */\nfunction createThunkMiddleware(extraArgument) {\n // Standard Redux middleware definition pattern:\n // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware\n var middleware = function middleware(_ref) {\n var dispatch = _ref.dispatch,\n getState = _ref.getState;\n return function (next) {\n return function (action) {\n // The thunk middleware looks for any functions that were passed to `store.dispatch`.\n // If this \"action\" is really a function, call it and return the result.\n if (typeof action === 'function') {\n // Inject the store's `dispatch` and `getState` methods, as well as any \"extra arg\"\n return action(dispatch, getState, extraArgument);\n } // Otherwise, pass the action down the middleware chain as usual\n\n\n return next(action);\n };\n };\n };\n\n return middleware;\n}\n\nvar thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version\n// with whatever \"extra arg\" they want to inject into their thunks\n\nthunk.withExtraArgument = createThunkMiddleware;\nexport default thunk;"]},"metadata":{},"sourceType":"module"}
|