1111return /******/ ( function ( modules ) { // webpackBootstrap
1212/******/ // The module cache
1313/******/ var installedModules = { } ;
14-
14+ /******/
1515/******/ // The require function
1616/******/ function __webpack_require__ ( moduleId ) {
17-
17+ /******/
1818/******/ // Check if module is in cache
1919/******/ if ( installedModules [ moduleId ] )
2020/******/ return installedModules [ moduleId ] . exports ;
21-
21+ /******/
2222/******/ // Create a new module (and put it into the cache)
2323/******/ var module = installedModules [ moduleId ] = {
2424/******/ i : moduleId ,
2525/******/ l : false ,
2626/******/ exports : { }
2727/******/ } ;
28-
28+ /******/
2929/******/ // Execute the module function
3030/******/ modules [ moduleId ] . call ( module . exports , module , module . exports , __webpack_require__ ) ;
31-
31+ /******/
3232/******/ // Flag the module as loaded
3333/******/ module . l = true ;
34-
34+ /******/
3535/******/ // Return the exports of the module
3636/******/ return module . exports ;
3737/******/ }
38-
39-
38+ /******/
39+ /******/
4040/******/ // expose the modules object (__webpack_modules__)
4141/******/ __webpack_require__ . m = modules ;
42-
42+ /******/
4343/******/ // expose the module cache
4444/******/ __webpack_require__ . c = installedModules ;
45-
45+ /******/
4646/******/ // identity function for calling harmony imports with the correct context
4747/******/ __webpack_require__ . i = function ( value ) { return value ; } ;
48-
48+ /******/
4949/******/ // define getter function for harmony exports
5050/******/ __webpack_require__ . d = function ( exports , name , getter ) {
5151/******/ if ( ! __webpack_require__ . o ( exports , name ) ) {
@@ -56,7 +56,7 @@ return /******/ (function(modules) { // webpackBootstrap
5656/******/ } ) ;
5757/******/ }
5858/******/ } ;
59-
59+ /******/
6060/******/ // getDefaultExport function for compatibility with non-harmony modules
6161/******/ __webpack_require__ . n = function ( module ) {
6262/******/ var getter = module && module . __esModule ?
@@ -65,13 +65,13 @@ return /******/ (function(modules) { // webpackBootstrap
6565/******/ __webpack_require__ . d ( getter , 'a' , getter ) ;
6666/******/ return getter ;
6767/******/ } ;
68-
68+ /******/
6969/******/ // Object.prototype.hasOwnProperty.call
7070/******/ __webpack_require__ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
71-
71+ /******/
7272/******/ // __webpack_public_path__
7373/******/ __webpack_require__ . p = "" ;
74-
74+ /******/
7575/******/ // Load entry module and return exports
7676/******/ return __webpack_require__ ( __webpack_require__ . s = 4 ) ;
7777/******/ } )
@@ -137,28 +137,33 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
137137
138138function _toConsumableArray ( arr ) { if ( Array . isArray ( arr ) ) { for ( var i = 0 , arr2 = Array ( arr . length ) ; i < arr . length ; i ++ ) { arr2 [ i ] = arr [ i ] ; } return arr2 ; } else { return Array . from ( arr ) ; } }
139139
140- function addInterceptor ( target , candidate , getState ) {
140+ function addInterceptor ( target , candidate , injectedParameters ) {
141141 if ( ! candidate ) return ;
142142 var successInterceptor = typeof candidate === 'function' ? candidate : candidate . success ;
143143 var errorInterceptor = candidate && candidate . error ;
144- target . use ( successInterceptor && successInterceptor . bind ( null , getState ) , errorInterceptor && errorInterceptor . bind ( null , getState ) ) ;
144+ target . use ( successInterceptor && successInterceptor . bind ( null , injectedParameters ) , errorInterceptor && errorInterceptor . bind ( null , injectedParameters ) ) ;
145145}
146146
147- function bindInterceptors ( client , getState ) {
147+ function bindInterceptors ( client , injectedParameters ) {
148148 var middlewareInterceptors = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
149149 var clientInterceptors = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : { } ;
150150
151151 [ ] . concat ( _toConsumableArray ( middlewareInterceptors . request || [ ] ) , _toConsumableArray ( clientInterceptors . request || [ ] ) ) . forEach ( function ( interceptor ) {
152- addInterceptor ( client . interceptors . request , interceptor , getState ) ;
152+ addInterceptor ( client . interceptors . request , interceptor , injectedParameters ) ;
153153 } ) ;
154154 [ ] . concat ( _toConsumableArray ( middlewareInterceptors . response || [ ] ) , _toConsumableArray ( clientInterceptors . response || [ ] ) ) . forEach ( function ( interceptor ) {
155- addInterceptor ( client . interceptors . response , interceptor , getState ) ;
155+ addInterceptor ( client . interceptors . response , interceptor , injectedParameters ) ;
156156 } ) ;
157157}
158158
159+ function getSourceAction ( config ) {
160+ return config . reduxSourceAction ;
161+ }
162+
159163var multiClientMiddleware = exports . multiClientMiddleware = function multiClientMiddleware ( clients , customMiddlewareOptions ) {
160164 var middlewareOptions = _extends ( { } , defaultOptions , customMiddlewareOptions ) ;
161165 var setupedClients = { } ;
166+
162167 return function ( _ref ) {
163168 var getState = _ref . getState ,
164169 dispatch = _ref . dispatch ;
@@ -167,20 +172,29 @@ var multiClientMiddleware = exports.multiClientMiddleware = function multiClient
167172 if ( ! middlewareOptions . isAxiosRequest ( action ) ) {
168173 return next ( action ) ;
169174 }
175+
170176 var clientName = middlewareOptions . getClientName ( action ) || middlewareOptions . defaultClientName ;
177+
171178 if ( ! clients [ clientName ] ) {
172179 throw new Error ( 'Client with name "' + clientName + '" has not been defined in middleware' ) ;
173180 }
181+
174182 if ( ! setupedClients [ clientName ] ) {
175183 var clientOptions = _extends ( { } , middlewareOptions , clients [ clientName ] . options ) ;
184+
176185 if ( clientOptions . interceptors ) {
177- bindInterceptors ( clients [ clientName ] . client , { getState : getState , dispatch : dispatch , action : action } , middlewareOptions . interceptors , clients [ clientName ] . options . interceptors ) ;
186+ var middlewareInterceptors = middlewareOptions . interceptors ;
187+ var clientInterceptors = clients [ clientName ] . options && clients [ clientName ] . options . interceptors ;
188+ var injectToInterceptor = { getState : getState , dispatch : dispatch , action : action , getSourceAction : getSourceAction } ;
189+ bindInterceptors ( clients [ clientName ] . client , injectToInterceptor , middlewareInterceptors , clientInterceptors ) ;
178190 }
191+
179192 setupedClients [ clientName ] = {
180193 client : clients [ clientName ] . client ,
181194 options : clientOptions
182195 } ;
183196 }
197+
184198 var setupedClient = setupedClients [ clientName ] ;
185199 var actionOptions = _extends ( { } , setupedClient . options , setupedClient . options . getRequestOptions ( action ) ) ;
186200
@@ -189,7 +203,11 @@ var multiClientMiddleware = exports.multiClientMiddleware = function multiClient
189203 REQUEST = _getActionTypes2 [ 0 ] ;
190204
191205 next ( _extends ( { } , action , { type : REQUEST } ) ) ;
192- return setupedClient . client . request ( actionOptions . getRequestConfig ( action ) ) . then ( function ( response ) {
206+
207+ var requestConfig = _extends ( { } , actionOptions . getRequestConfig ( action ) , {
208+ reduxSourceAction : action
209+ } ) ;
210+ return setupedClient . client . request ( requestConfig ) . then ( function ( response ) {
193211 var newAction = actionOptions . onSuccess ( { action : action , next : next , response : response , getState : getState , dispatch : dispatch } , actionOptions ) ;
194212 actionOptions . onComplete ( { action : newAction , next : next , getState : getState , dispatch : dispatch } , actionOptions ) ;
195213 return newAction ;
0 commit comments