UNPKG

stripe-redux-promise-middleware

Version:

Redux middleware for handling promises and optimistic updates

1 lines 2.83 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReduxPromiseMiddleware=e():t.ReduxPromiseMiddleware=e()}(this,function(){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.promiseTypeSuffixes||c;return function(t){var o=t.dispatch;return function(t){return function(n){if(!n.payload)return t(n);if(!(0,l.default)(n.payload)&&!(0,l.default)(n.payload.promise))return t(n);var r=n.type,a=n.payload,c=n.meta,y=f(e,3),p=y[0],d=y[1],s=y[2],m=function(t,e){return i({type:r+"_"+(e?s:d)},null===t||"undefined"==typeof t?{}:{payload:t},c?{meta:c}:{},e?{error:!0}:{})},b=void 0,v=void 0;(0,l.default)(n.payload)||"object"!==u(n.payload)?(b=a,v=null):(b=a.promise,v=a.data),t(i({type:r+"_"+p},v?{payload:v}:{},c?{meta:c}:{}));var h=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=m(t,!1);return{value:t,action:e}},x=function(t){var e=m(t,!0);o(e)},S=function(t){o(t.action)},w=b.then(h),j=w.then(S,x).catch(function(t){window&&"function"==typeof window.onerror&&window.onerror(t)});return j.then(function(){return w},function(){return w})}}}}Object.defineProperty(e,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},f=function(){function t(t,e){var o=[],n=!0,r=!1,u=void 0;try{for(var i,f=t[Symbol.iterator]();!(n=(i=f.next()).done)&&(o.push(i.value),!e||o.length!==e);n=!0);}catch(t){r=!0,u=t}finally{try{!n&&f.return&&f.return()}finally{if(r)throw u}}return o}return function(e,o){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,o);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.default=r;var a=o(1),l=n(a),c=["PENDING","FULFILLED","REJECTED"]},function(t,e){"use strict";function o(t){return null!==t&&"object"===("undefined"==typeof t?"undefined":n(t))&&(t&&"function"==typeof t.then)}Object.defineProperty(e,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.default=o}])});