snapsheet-redux-helpers
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,2 +1,5 @@ | ||
# 1.0.1 | ||
Fix: store.dispatch.then() not returning response data | ||
# 1.0.0 | ||
Initial version |
@@ -82,3 +82,3 @@ 'use strict'; | ||
}); | ||
return data; | ||
return response; | ||
}, function (error) { | ||
@@ -85,0 +85,0 @@ if (process.env.NODE_ENV === 'development') { |
@@ -76,5 +76,5 @@ 'use strict'; | ||
(0, _ava2.default)('Error ajax call', function () { | ||
(0, _ava2.default)('Response accessible in after callback', function () { | ||
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(t) { | ||
var store, error, actions; | ||
var store, responseData, actions; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
@@ -85,2 +85,47 @@ while (1) { | ||
store = t.context.mockStore({}); | ||
responseData = { | ||
result: 'IT WORKED' | ||
}; | ||
t.context.ApiClient.prototype.getJson = _sinon2.default.mock().returns(Promise.resolve(responseData)); | ||
_context2.next = 5; | ||
return store.dispatch({ | ||
types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
ajax: function ajax(apiClient) { | ||
return apiClient.getJson('/test'); | ||
} | ||
}).then(function (response) { | ||
return store.dispatch({ data: response, type: 'HANDLER' }); | ||
}); | ||
case 5: | ||
actions = store.getActions(); | ||
t.is(actions[0].type, FETCH); | ||
t.is(actions[1].type, FETCH_SUCCESS); | ||
t.is(actions[1].response, responseData); | ||
t.is(actions[2].data, responseData); | ||
case 10: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
})); | ||
return function (_x2) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}()); | ||
(0, _ava2.default)('Error ajax call', function () { | ||
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(t) { | ||
var store, error, actions; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
store = t.context.mockStore({}); | ||
error = { | ||
@@ -92,3 +137,3 @@ message: 'uh oh something happened' | ||
_context2.next = 5; | ||
_context3.next = 5; | ||
return store.dispatch({ | ||
@@ -113,10 +158,10 @@ types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
case 'end': | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
}, _callee3, undefined); | ||
})); | ||
return function (_x2) { | ||
return _ref2.apply(this, arguments); | ||
return function (_x3) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
@@ -126,7 +171,7 @@ }()); | ||
(0, _ava2.default)('shouldPerform prevents perform', function () { | ||
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(t) { | ||
var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(t) { | ||
var store, result, actions; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
@@ -139,3 +184,3 @@ store = t.context.mockStore({ | ||
_context3.next = 4; | ||
_context4.next = 4; | ||
return store.dispatch({ | ||
@@ -152,3 +197,3 @@ shouldPerform: function shouldPerform(getState) { | ||
case 4: | ||
result = _context3.sent; | ||
result = _context4.sent; | ||
actions = store.getActions(); | ||
@@ -161,10 +206,10 @@ | ||
case 'end': | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee3, undefined); | ||
}, _callee4, undefined); | ||
})); | ||
return function (_x3) { | ||
return _ref3.apply(this, arguments); | ||
return function (_x4) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
@@ -174,7 +219,7 @@ }()); | ||
(0, _ava2.default)('success action finishes before the `after` callback: (...) => promise.then', function () { | ||
var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(t) { | ||
var _ref5 = _asyncToGenerator(regeneratorRuntime.mark(function _callee5(t) { | ||
var store, actions; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
@@ -187,3 +232,3 @@ store = t.context.mockStore({ | ||
_context4.next = 4; | ||
_context5.next = 4; | ||
return store.dispatch({ | ||
@@ -208,11 +253,11 @@ types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
case 'end': | ||
return _context4.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee4, undefined); | ||
}, _callee5, undefined); | ||
})); | ||
return function (_x4) { | ||
return _ref4.apply(this, arguments); | ||
return function (_x5) { | ||
return _ref5.apply(this, arguments); | ||
}; | ||
}()); |
@@ -82,3 +82,3 @@ 'use strict'; | ||
}); | ||
return data; | ||
return response; | ||
}, function (error) { | ||
@@ -85,0 +85,0 @@ if (process.env.NODE_ENV === 'development') { |
@@ -76,5 +76,5 @@ 'use strict'; | ||
(0, _ava2.default)('Error ajax call', function () { | ||
(0, _ava2.default)('Response accessible in after callback', function () { | ||
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2(t) { | ||
var store, error, actions; | ||
var store, responseData, actions; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
@@ -85,2 +85,47 @@ while (1) { | ||
store = t.context.mockStore({}); | ||
responseData = { | ||
result: 'IT WORKED' | ||
}; | ||
t.context.ApiClient.prototype.getJson = _sinon2.default.mock().returns(Promise.resolve(responseData)); | ||
_context2.next = 5; | ||
return store.dispatch({ | ||
types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
ajax: function ajax(apiClient) { | ||
return apiClient.getJson('/test'); | ||
} | ||
}).then(function (response) { | ||
return store.dispatch({ data: response, type: 'HANDLER' }); | ||
}); | ||
case 5: | ||
actions = store.getActions(); | ||
t.is(actions[0].type, FETCH); | ||
t.is(actions[1].type, FETCH_SUCCESS); | ||
t.is(actions[1].response, responseData); | ||
t.is(actions[2].data, responseData); | ||
case 10: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
})); | ||
return function (_x2) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}()); | ||
(0, _ava2.default)('Error ajax call', function () { | ||
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(t) { | ||
var store, error, actions; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
store = t.context.mockStore({}); | ||
error = { | ||
@@ -92,3 +137,3 @@ message: 'uh oh something happened' | ||
_context2.next = 5; | ||
_context3.next = 5; | ||
return store.dispatch({ | ||
@@ -113,10 +158,10 @@ types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
case 'end': | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
}, _callee3, undefined); | ||
})); | ||
return function (_x2) { | ||
return _ref2.apply(this, arguments); | ||
return function (_x3) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
@@ -126,7 +171,7 @@ }()); | ||
(0, _ava2.default)('shouldPerform prevents perform', function () { | ||
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3(t) { | ||
var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(t) { | ||
var store, result, actions; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
@@ -139,3 +184,3 @@ store = t.context.mockStore({ | ||
_context3.next = 4; | ||
_context4.next = 4; | ||
return store.dispatch({ | ||
@@ -152,3 +197,3 @@ shouldPerform: function shouldPerform(getState) { | ||
case 4: | ||
result = _context3.sent; | ||
result = _context4.sent; | ||
actions = store.getActions(); | ||
@@ -161,10 +206,10 @@ | ||
case 'end': | ||
return _context3.stop(); | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee3, undefined); | ||
}, _callee4, undefined); | ||
})); | ||
return function (_x3) { | ||
return _ref3.apply(this, arguments); | ||
return function (_x4) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
@@ -174,7 +219,7 @@ }()); | ||
(0, _ava2.default)('success action finishes before the `after` callback: (...) => promise.then', function () { | ||
var _ref4 = _asyncToGenerator(regeneratorRuntime.mark(function _callee4(t) { | ||
var _ref5 = _asyncToGenerator(regeneratorRuntime.mark(function _callee5(t) { | ||
var store, actions; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
@@ -187,3 +232,3 @@ store = t.context.mockStore({ | ||
_context4.next = 4; | ||
_context5.next = 4; | ||
return store.dispatch({ | ||
@@ -208,11 +253,11 @@ types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
case 'end': | ||
return _context4.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee4, undefined); | ||
}, _callee5, undefined); | ||
})); | ||
return function (_x4) { | ||
return _ref4.apply(this, arguments); | ||
return function (_x5) { | ||
return _ref5.apply(this, arguments); | ||
}; | ||
}()); |
{ | ||
"name": "snapsheet-redux-helpers", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "lib/index", | ||
@@ -5,0 +5,0 @@ "jsnext:main": "es6/index", |
# snapsheet-redux-helpers | ||
Helpers to reduce boilerplate with redux. | ||
[![npm version](https://img.shields.io/npm/v/snapsheet-redux-helpers.svg?style=flat-square)](https://www.npmjs.com/package/snapsheet-redux-helpers) | ||
[![npm downloads](https://img.shields.io/npm/dm/snapsheet-redux-helpers.svg?style=flat-square)](https://www.npmjs.com/package/snapsheet-redux-helpers) | ||
[![Build Status](https://travis-ci.org/bodyshopbidsdotcom/redux-helpers.svg?branch=master)](https://travis-ci.org/bodyshopbidsdotcom/redux-helpers) | ||
## Installation | ||
$ npm install snapsheet-redux-helpers --save | ||
or with yarn | ||
$ yarn add snapsheet-redux-helpers | ||
## Api middleware | ||
Using the api middleware reduces boilerplate for async actions. Instead of writing actions for your apis like this: | ||
```javascript | ||
export function login(username, password) { | ||
return (dispatch, getState) => { | ||
dispatch({ type: 'LOGIN' }); | ||
return postJSON('/api/v1/login', { username, password }).then( | ||
(data) => { | ||
dispatch({ type: 'LOGIN_SUCCESS', result: data }); | ||
return data; | ||
}, | ||
(error) => { | ||
// handle error | ||
dispatch({ type: 'LOGIN_ERROR', error: error }) | ||
return Promise.reject(error); | ||
} | ||
); | ||
} | ||
} | ||
``` | ||
You can write them like this with the use of AjaxAction: | ||
```javascript | ||
export function login(username, password) { | ||
return new AjaxAction('LOGIN') | ||
.call((apiClient) => apiClient.postJSON('/api/v1/login', { username, password })) | ||
.toReduxAction(); | ||
} | ||
``` | ||
### Setting up api middleware | ||
```javascript | ||
import { createApiMiddleware } from 'snapsheet-redux-helpers'; | ||
``` | ||
You can also minimize the bundle by importing only the files you need | ||
```javascript | ||
import createApiMiddleware from 'snapsheet-redux-helpers/lib/createApiMiddleware'; | ||
``` | ||
```javascript | ||
const middleware = [ | ||
createApiMiddleware(ApiClient) | ||
]; | ||
const store = createStore(rootReducer, composeEnhancers( | ||
applyMiddleware(...middleware) | ||
)); | ||
``` | ||
**NOTE**: you will need an ApiClient model to use. See [SampleApiClient](https://github.com/bodyshopbidsdotcom/redux-helpers/blob/master/demo/SampleApiClient.js) for | ||
an example of how it could be setup. It should accept `dispatch, getState` in the constructor, but the rest is up to you! This allows you to generalize what happens whenever an ajax call is made, such as beginning a loading indicator, | ||
displaying flash messages when an error occurs, or automatically adding params to requests. It also | ||
gives you the freedom to use other libraries to make your requests. The only limitation is that each | ||
action should return a `Promise`. | ||
See [demo/index.js](https://github.com/bodyshopbidsdotcom/redux-helpers/blob/master/demo/index.js) for more example usage. | ||
## Demo | ||
$ git clone https://github.com/bodyshopbidsdotcom/redux-helpers.git | ||
$ cd redux-helpers | ||
$ npm install | ||
$ npm run demo | ||
$ open http://localhost:3000 | ||
## Contributing | ||
Please create an issue with any feature suggestions or bug reports. Pull requests are welcome. |
@@ -62,3 +62,3 @@ /** | ||
}); | ||
return data; | ||
return response; | ||
}, | ||
@@ -65,0 +65,0 @@ error => { |
@@ -35,2 +35,23 @@ import test from 'ava'; | ||
test('Response accessible in after callback', async t => { | ||
const store = t.context.mockStore({}); | ||
const responseData = { | ||
result: 'IT WORKED' | ||
}; | ||
t.context.ApiClient.prototype.getJson = sinon.mock().returns(Promise.resolve(responseData)); | ||
await store.dispatch({ | ||
types: [FETCH, FETCH_SUCCESS, FETCH_ERROR], | ||
ajax: (apiClient) => apiClient.getJson('/test') | ||
}).then(response => { | ||
return store.dispatch({ data: response, type: 'HANDLER'}); | ||
}); | ||
const actions = store.getActions(); | ||
t.is(actions[0].type, FETCH); | ||
t.is(actions[1].type, FETCH_SUCCESS); | ||
t.is(actions[1].response, responseData); | ||
t.is(actions[2].data, responseData); | ||
}); | ||
test('Error ajax call', async t => { | ||
@@ -37,0 +58,0 @@ const store = t.context.mockStore({}); |
@@ -435,3 +435,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
}); | ||
return data; | ||
return response; | ||
}, function (error) { | ||
@@ -438,0 +438,0 @@ if (true) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["snapsheet-redux-helpers"]=t():e["snapsheet-redux-helpers"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function n(e,t){return a({type:e,status:t},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function o(e){return function(t){return n(e,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}}function u(e){return{error:e+"_ERROR",pending:e+"_PENDING",success:e+"_SUCCESS"}}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.createAction=n,t.createActionCreator=o,t.getAjaxTypes=u;t.FetchStatus={SUCCESS:"SUCCESS",ERROR:"ERROR",PENDING:"PENDING"}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createApiMiddleware=t.createReducer=t.createAjaxHandlers=t.AjaxAction=void 0;var o=r(0);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var u=r(3),a=n(u),c=r(4),i=n(c),f=r(5),s=n(f),l=r(6),d=n(l);t.AjaxAction=a.default,t.createAjaxHandlers=i.default,t.createReducer=s.default,t.createApiMiddleware=d.default},function(e,t,r){r(1),e.exports=r(1)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(){function e(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(0),a=["call","data","force","skipIfInCache","shouldPerform"];t.default=function(){function e(t){var r=this;n(this,e),this._locals={types:(0,u.getAjaxTypes)(t)},a.forEach(function(e){r[e]=function(t){return r._locals[e]=t,r}})}return o(e,[{key:"toReduxAction",value:function(){var e=this._locals,t=e.call,r=e.data,n=e.force,o=e.skipIfInCache,u=e.shouldPerform,a=e.types;return{ajax:t,types:[a.pending,a.success,a.error],data:r,shouldPerform:u,checkIfInCache:o,force:n}}}]),e}()},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t,r,o,u){var c=u&&u(e,t)||{};return a({},e,c,n({},r,o))}function u(e,t){var r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=(0,c.getAjaxTypes)(e),i=a.pending,f=a.success,s=a.error,l=u.pending,d=u.success,p=u.error;return r={},n(r,i,function(e,r){return o(e,r,t,c.FetchStatus.PENDING,l)}),n(r,f,function(e,r){return o(e,r,t,c.FetchStatus.SUCCESS,d)}),n(r,s,function(e,r){return o(e,r,t,c.FetchStatus.ERROR,p)}),r}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=u;var c=r(0)},function(e,t,r){"use strict";function n(e,t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments[1],o=n.type;return t[o]?t[o](r,n):r}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){"use strict";function n(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(u){if("function"==typeof u)return u(r,n);var a=u.ajax,c=u.types,i=u.data;if(!a||!c)return t(u);if(!u.force){if(u.shouldPerform&&!u.shouldPerform(n))return Promise.resolve("skipped");if(u.checkIfInCache&&u.checkIfInCache(n))return Promise.resolve("from cache")}var f=o(c,3),s=f[1],l=f[2];return t({data:i,type:f[0]}),a(new e(r,n)).then(function(e){return t({data:i,response:e,type:s}),i},function(e){return t({data:i,error:e,type:l}),Promise.reject(e)})}}}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){var r=[],n=!0,o=!1,u=void 0;try{for(var a,c=e[Symbol.iterator]();!(n=(a=c.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{!n&&c.return&&c.return()}finally{if(o)throw u}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=n}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["snapsheet-redux-helpers"]=t():e["snapsheet-redux-helpers"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function n(e,t){return a({type:e,status:t},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function o(e){return function(t){return n(e,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}}function u(e){return{error:e+"_ERROR",pending:e+"_PENDING",success:e+"_SUCCESS"}}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.createAction=n,t.createActionCreator=o,t.getAjaxTypes=u;t.FetchStatus={SUCCESS:"SUCCESS",ERROR:"ERROR",PENDING:"PENDING"}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.createApiMiddleware=t.createReducer=t.createAjaxHandlers=t.AjaxAction=void 0;var o=r(0);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var u=r(3),a=n(u),c=r(4),i=n(c),f=r(5),s=n(f),l=r(6),d=n(l);t.AjaxAction=a.default,t.createAjaxHandlers=i.default,t.createReducer=s.default,t.createApiMiddleware=d.default},function(e,t,r){r(1),e.exports=r(1)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(){function e(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r(0),a=["call","data","force","skipIfInCache","shouldPerform"];t.default=function(){function e(t){var r=this;n(this,e),this._locals={types:(0,u.getAjaxTypes)(t)},a.forEach(function(e){r[e]=function(t){return r._locals[e]=t,r}})}return o(e,[{key:"toReduxAction",value:function(){var e=this._locals,t=e.call,r=e.data,n=e.force,o=e.skipIfInCache,u=e.shouldPerform,a=e.types;return{ajax:t,types:[a.pending,a.success,a.error],data:r,shouldPerform:u,checkIfInCache:o,force:n}}}]),e}()},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t,r,o,u){var c=u&&u(e,t)||{};return a({},e,c,n({},r,o))}function u(e,t){var r,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=(0,c.getAjaxTypes)(e),i=a.pending,f=a.success,s=a.error,l=u.pending,d=u.success,p=u.error;return r={},n(r,i,function(e,r){return o(e,r,t,c.FetchStatus.PENDING,l)}),n(r,f,function(e,r){return o(e,r,t,c.FetchStatus.SUCCESS,d)}),n(r,s,function(e,r){return o(e,r,t,c.FetchStatus.ERROR,p)}),r}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=u;var c=r(0)},function(e,t,r){"use strict";function n(e,t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments[1],o=n.type;return t[o]?t[o](r,n):r}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){"use strict";function n(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(u){if("function"==typeof u)return u(r,n);var a=u.ajax,c=u.types,i=u.data;if(!a||!c)return t(u);if(!u.force){if(u.shouldPerform&&!u.shouldPerform(n))return Promise.resolve("skipped");if(u.checkIfInCache&&u.checkIfInCache(n))return Promise.resolve("from cache")}var f=o(c,3),s=f[1],l=f[2];return t({data:i,type:f[0]}),a(new e(r,n)).then(function(e){return t({data:i,response:e,type:s}),e},function(e){return t({data:i,error:e,type:l}),Promise.reject(e)})}}}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){var r=[],n=!0,o=!1,u=void 0;try{for(var a,c=e[Symbol.iterator]();!(n=(a=c.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{!n&&c.return&&c.return()}finally{if(o)throw u}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=n}])}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77444
1616
89