redux-saga
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -1179,4 +1179,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function _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); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -1226,7 +1224,9 @@ | ||
function takeEvery(pattern, worker) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
var yieldTake = { done: false, value: (0, _io.take)(pattern) }; | ||
var yieldFork = function yieldFork(action) { | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(_toConsumableArray(args), [action])) }; | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [action])) }; | ||
}; | ||
@@ -1241,7 +1241,9 @@ | ||
function takeLatest(pattern, worker) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
} | ||
var yieldTake = { done: false, value: (0, _io.take)(pattern) }; | ||
var yieldFork = function yieldFork() { | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(_toConsumableArray(args), [currentAction])) }; | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [currentAction])) }; | ||
}; | ||
@@ -1248,0 +1250,0 @@ var yieldCancel = function yieldCancel() { |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReduxSaga=e():n.ReduxSaga=e()}(this,function(){return function(n){function e(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return n[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n,e,t){"use strict";function r(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function u(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.effects=e.takeLatest=e.takeEvery=e.storeIO=e.runSaga=e.isCancelError=e.SagaCancellationException=void 0;var o=t(9);Object.defineProperty(e,"runSaga",{enumerable:!0,get:function(){return o.runSaga}}),Object.defineProperty(e,"storeIO",{enumerable:!0,get:function(){return o.storeIO}});var a=t(10);Object.defineProperty(e,"takeEvery",{enumerable:!0,get:function(){return a.takeEvery}}),Object.defineProperty(e,"takeLatest",{enumerable:!0,get:function(){return a.takeLatest}});var i=t(8),c=u(i),f=t(2),s=u(f),l=t(7),d=r(l),v=t(12),p=r(v);e.default=c.default;var g=e.SagaCancellationException=s.default;e.isCancelError=function(n){return n instanceof g};e.effects=d,e.utils=p},function(n,e,t){(function(n){"use strict";function t(n,e,t){if(!e(n))throw new Error(t)}function r(n,e){var t=n.indexOf(e);t>=0&&n.splice(t,1)}function u(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=c({},n),t=new Promise(function(n,t){e.resolve=n,e.reject=t});return e.promise=t,e}function o(n){for(var e=[],t=0;n>t;t++)e.push(u());return e}function a(){var n=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++n}}function i(n){return Promise.resolve(1).then(function(){return n()})}var c=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.check=t,e.remove=r,e.deferred=u,e.arrayOfDeffered=o,e.autoInc=a,e.asap=i;var f=e.TASK=Symbol("TASK"),s=(e.kTrue=function(){return!0},e.noop=function(){},e.isDev="undefined"!=typeof n&&n.env&&!1,e.is={undef:function(n){return null===n||void 0===n},notUndef:function(n){return null!==n&&void 0!==n},func:function(n){return"function"==typeof n},array:Array.isArray,promise:function(n){return n&&s.func(n.then)},iterator:function(n){return n&&s.func(n.next)&&s.func(n[Symbol.iterator])},"throw":function(n){return n&&s.func(n.throw)},task:function(n){return n&&n[f]}})}).call(e,t(13))},function(n,e){"use strict";function t(n,e,t){var r="SagaCancellationException; type: "+n+", saga: "+e+", origin: "+t;this.name="SagaCancellationException",this.message=r,this.type=n,this.saga=e,this.origin=t,this.stack=(new Error).stack}Object.defineProperty(e,"__esModule",{value:!0}),e.default=t,t.prototype=Object.create(Error.prototype),t.prototype.constructor=t},function(n,e,t){"use strict";function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function u(n){return("*"===n?j.wildcard:m.is.array(n)?j.array:m.is.func(n)?j.predicate:j.default)(n)}function o(n){if(arguments.length>0&&m.is.undef(n))throw new Error(A);return N(R,m.is.undef(n)?"*":n)}function a(n){return N(O,n)}function i(n){return N(b,n)}function c(n,e){(0,m.check)(n,m.is.notUndef,h);var t=null;if(m.is.array(n)){var r=n,u=g(r,2);t=u[0],n=u[1]}else if(n.fn){var o=n;t=o.context,n=o.fn}return(0,m.check)(n,m.is.func,h),{context:t,fn:n,args:e}}function f(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(C,c(n,t))}function s(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return N(C,c({context:n,fn:e},t))}function l(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(T,c(n,t))}function d(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(w,c(n,t))}function v(n){if(!I(n))throw new Error(y);return N(k,n)}function p(n){if(!I(n))throw new Error(E);return N(L,n)}var g=function(){function n(n,e){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=n[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.asEffect=e.INVALID_PATTERN=e.CANCEL_ARG_ERROR=e.JOIN_ARG_ERROR=e.FORK_ARG_ERROR=e.CALL_FUNCTION_ARG_ERROR=void 0,e.matcher=u,e.take=o,e.put=a,e.race=i,e.call=f,e.apply=s,e.cps=l,e.fork=d,e.join=v,e.cancel=p;var m=t(1),h=e.CALL_FUNCTION_ARG_ERROR="call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}",y=(e.FORK_ARG_ERROR="fork first argument must be a generator function or an iterator",e.JOIN_ARG_ERROR="join argument must be a valid task (a result of a fork)"),E=e.CANCEL_ARG_ERROR="cancel argument must be a valid task (a result of a fork)",A=e.INVALID_PATTERN="Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)",_=Symbol("IO"),R="TAKE",O="PUT",b="RACE",C="CALL",T="CPS",w="FORK",k="JOIN",L="CANCEL",N=function(n,e){var t;return t={},r(t,_,!0),r(t,n,e),t},j={wildcard:function(){return m.kTrue},"default":function(n){return function(e){return e.type===n}},array:function(n){return function(e){return n.some(function(n){return n===e.type})}},predicate:function(n){return function(e){return n(e)}}},I=function(n){return n[m.TASK]};e.asEffect={take:function(n){return n&&n[_]&&n[R]},put:function(n){return n&&n[_]&&n[O]},race:function(n){return n&&n[_]&&n[b]},call:function(n){return n&&n[_]&&n[C]},cps:function(n){return n&&n[_]&&n[T]},fork:function(n){return n&&n[_]&&n[w]},join:function(n){return n&&n[_]&&n[k]},cancel:function(n){return n&&n[_]&&n[L]}}},function(n,e){"use strict";function t(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n,e,r,u){var o;return o={},t(o,a,!0),t(o,"type",i),t(o,"effectId",n),t(o,"parentEffectId",e),t(o,"label",r),t(o,"effect",u),o}function u(n,e){var r;return r={},t(r,a,!0),t(r,"type",c),t(r,"effectId",n),t(r,"result",e),r}function o(n,e){var r;return r={},t(r,a,!0),t(r,"type",f),t(r,"effectId",n),t(r,"error",e),r}Object.defineProperty(e,"__esModule",{value:!0}),e.effectTriggered=r,e.effectResolved=u,e.effectRejected=o;var a=e.MONITOR_ACTION="MONITOR_ACTION",i=e.EFFECT_TRIGGERED="EFFECT_TRIGGERED",c=e.EFFECT_RESOLVED="EFFECT_RESOLVED",f=e.EFFECT_REJECTED="EFFECT_REJECTED"},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function a(n){function e(u,o){if(!n._isRunning)throw new Error("Trying to resume an already finished generator");try{if(u&&!M)throw u;var a=u?n.throw(u):n.next(o);a.done?t(a.value):r(a.value,I,"",e)}catch(u){if(t(u,!0),!(u instanceof d.default))throw u;i.isDev&&console.warn(S+": uncaught",u)}}function t(e,t){n._isRunning=!1,t?(n._error=e,U.reject(e)):(n._result=e,U.resolve(e)),D()}function r(n,e){function t(n,e){d||(d=!0,o.cancel=i.noop,j(n?s.effectRejected(a,n):s.effectResolved(a,e)),o(n,e))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],o=arguments[3],a=E();j(s.effectTriggered(a,e,r,n));var d=void 0;t.cancel=i.noop,o.cancel=function(n){if(!d){d=!0;try{t.cancel(n)}catch(e){}t.cancel=i.noop,o(n),j(s.effectRejected(a,n))}};var v=void 0;return i.is.promise(n)?u(n,t):i.is.iterator(n)?f(n,a,S,t):i.is.array(n)?T(n,a,t):i.is.notUndef(v=c.asEffect.take(n))?l(v,t):i.is.notUndef(v=c.asEffect.put(n))?A(v,t):i.is.notUndef(v=c.asEffect.race(n))?w(v,a,t):i.is.notUndef(v=c.asEffect.call(n))?_(v,a,t):i.is.notUndef(v=c.asEffect.cps(n))?R(v,t):i.is.notUndef(v=c.asEffect.fork(n))?O(v,a,t):i.is.notUndef(v=c.asEffect.join(n))?b(v,t):i.is.notUndef(v=c.asEffect.cancel(n))?C(v,t):t(null,n)}function u(n,e){var t=n[g];"function"==typeof t&&(e.cancel=t),n.then(function(n){return e(null,n)},function(n){return e(n)})}function f(n,e,t,r){u(a(n,L,N,j,e,t).done,r)}function l(n,e){var t={match:(0,c.matcher)(n),pattern:n,resolve:function(n){return e(null,n)}};P.push(t),e.cancel=function(){return(0,i.remove)(P,t)}}function A(n,e){(0,i.asap)(function(){return e(null,N(n))})}function _(n,e,t){var r=n.context,o=n.fn,a=n.args,c=o.apply(r,a);return i.is.promise(c)?u(c,t):i.is.iterator(c)?f(c,e,o.name,t):t(null,c)}function R(n,e){var t=n.context,r=n.fn,u=n.args;r.apply(t,u.concat(e))}function O(n,e,t){var r=n.context,u=n.fn,o=n.args,c=void 0,f=void 0;c=u.apply(r,o),f=i.is.iterator(c)?c:regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,c;case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},s,this)})(),t(null,a(f,L,N,j,e,u.name,!0))}function b(n,e){u(n.done,e)}function C(n,e){n.done[g](new d.default(y,S,S)),e()}function T(n,e,t){function u(){o===c.length&&(a=!0,t(null,c))}if(!n.length)return void t(null,[]);var o=0,a=void 0,c=Array(n.length),f=n.map(function(n,e){var r=function(n,r){if(!a)if(n){try{t.cancel(new d.default(m,S,S))}catch(n){}t(n)}else c[e]=r,o++,u()};return r.cancel=i.noop,r});t.cancel=function(n){a||(a=!0,f.forEach(function(e){return e.cancel(n)}))},n.forEach(function(n,t){return r(n,e,t,f[t])})}function w(n,e,t){var u=void 0,a=Object.keys(n),c={};a.forEach(function(n){var e=function(e,r){if(!u)if(e){try{t.cancel(new d.default(h,S,S))}catch(e){}t(o({},n,e))}else{try{t.cancel(new d.default(h,S,S))}catch(e){}u=!0,t(null,o({},n,r))}};e.cancel=i.noop,c[n]=e}),t.cancel=function(n){u||(u=!0,a.forEach(function(e){return c[e].cancel(n)}))},a.forEach(function(t){return r(n[t],e,t,c[t])})}function k(n,e,t,r,u){var a;return a={},o(a,i.TASK,!0),o(a,"id",n),o(a,"name",e),o(a,"done",r),o(a,"forked",u),o(a,"cancel",function(n){n instanceof d.default||(n=new d.default(y,e,n)),r[g](n)}),o(a,"isRunning",function(){return t._isRunning}),o(a,"getResult",function(){return t._result}),o(a,"getError",function(){return t._error}),a}var L=arguments.length<=1||void 0===arguments[1]?function(){return i.noop}:arguments[1],N=arguments.length<=2||void 0===arguments[2]?i.noop:arguments[2],j=arguments.length<=3||void 0===arguments[3]?i.noop:arguments[3],I=arguments.length<=4||void 0===arguments[4]?0:arguments[4],S=arguments.length<=5||void 0===arguments[5]?"anonymous":arguments[5];(0,i.check)(n,i.is.iterator,v);var x=p(S),P=[],M=i.is.throw(n),U=(0,i.deferred)(),D=L(function(n){if(void 0===n)throw x;for(var e=0;e<P.length;e++){var t=P[e];t.match(n)&&(P=[],t.resolve(n))}});e.cancel=i.noop;var F=k(I,S,n,U.promise);return F.done[g]=function(n){var t=n.type,r=n.origin;e.cancel(new d.default(t,S,r))},n._isRunning=!0,e(),F}Object.defineProperty(e,"__esModule",{value:!0}),e.MANUAL_CANCEL=e.RACE_AUTO_CANCEL=e.PARALLEL_AUTO_CANCEL=e.CANCEL=e.undefindInputError=e.NOT_ITERATOR_ERROR=void 0,e.default=a;var i=t(1),c=t(3),f=t(4),s=u(f),l=t(2),d=r(l),v=e.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",p=e.undefindInputError=function(n){return"\n "+n+" saga was provided with an undefined input action\n Hints :\n - check that your Action Creator returns a non undefined value\n - if the Saga was started using runSaga, check that your subscribe source provides the action to its listeners\n"},g=e.CANCEL=Symbol("@@redux-saga/cancelPromise"),m=e.PARALLEL_AUTO_CANCEL="PARALLEL_AUTO_CANCEL",h=e.RACE_AUTO_CANCEL="RACE_AUTO_CANCEL",y=e.MANUAL_CANCEL="MANUAL_CANCEL",E=(0,i.autoInc)()},function(n,e,t){"use strict";function r(){function n(n){return t.push(n),function(){return(0,u.remove)(t,n)}}function e(n){t.slice().forEach(function(e){return e(n)})}var t=[];return{subscribe:n,emit:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var u=t(1)},function(n,e,t){"use strict";var r=t(3);n.exports={take:r.take,put:r.put,race:r.race,call:r.call,apply:r.apply,cps:r.cps,fork:r.fork,join:r.join,cancel:r.cancel}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(){function n(n){function e(n){for(var e=arguments.length,t=Array(e>1?e-1:0),u=1;e>u;u++)t[u-1]=arguments[u];return(0,i.default)(n.apply(void 0,[r].concat(t)),c.subscribe,a,l,0,n.name)}var r=n.getState,a=n.dispatch,c=(0,f.default)(),l=o.isDev?function(n){return(0,o.asap)(function(){return a(n)})}:void 0;return u=e,t.forEach(e),function(n){return function(e){var t=n(e);return e[s.MONITOR_ACTION]||c.emit(e),t}}}for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var u=void 0;return n.run=function(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];if(!u)throw new Error(v);var o=u.apply(void 0,[n].concat(t));return o.done.catch(function(n){if(!(n instanceof d.default))throw n}),o},n}Object.defineProperty(e,"__esModule",{value:!0}),e.RUN_SAGA_DYNAMIC_ERROR=void 0,e.default=u;var o=t(1),a=t(5),i=r(a),c=t(6),f=r(c),s=t(4),l=t(2),d=r(l),v=e.RUN_SAGA_DYNAMIC_ERROR="Before running a Saga dynamically using middleware.run, you must mount the Saga middleware on the Store using applyMiddleware"},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(a.isDev&&console.warn("storeIO is deprecated, to run Saga dynamically, use 'run' method of the middleware"),n[d])return n[d];var e=(0,s.default)(),t=n.dispatch;return n.dispatch=function(n){var r=t(n);return e.emit(n),r},n[d]={subscribe:e.subscribe,dispatch:n.dispatch},n[d]}function o(n,e){var t=e.subscribe,r=e.dispatch,u=arguments.length<=2||void 0===arguments[2]?a.noop:arguments[2];return(0,a.check)(n,a.is.iterator,l),(0,c.default)(n,t,r,u)}Object.defineProperty(e,"__esModule",{value:!0}),e.NOT_ITERATOR_ERROR=void 0,e.storeIO=u,e.runSaga=o;var a=t(1),i=t(5),c=r(i),f=t(6),s=r(f),l=e.NOT_ITERATOR_ERROR="runSaga must be called on an iterator",d=Symbol("IO")},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(Array.isArray(n)){for(var e=0,t=Array(n.length);e<n.length;e++)t[e]=n[e];return t}return Array.from(n)}function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function a(n,e){function t(t,r){if(u)return g;if(r){if(u=!0,!(r instanceof v.default))throw r;return g}a&&a(t);var o=f(n[e],3),i=o[0],c=o[1],s=o[2];return a=s,e=p(c,t),p(i,t)}var r,u=void 0,a=void 0,i=(r={},o(r,Symbol.iterator,function(){return i}),o(r,"next",t),o(r,"throw",function(n){return t(null,n)}),r);return i}function i(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2],r={done:!1,value:(0,l.take)(n)},o=function(n){return{done:!1,value:l.fork.apply(void 0,[e].concat(u(t),[n]))}};return a({take:[r,"fork"],fork:[o,"take"]},"take")}function c(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2],r={done:!1,value:(0,l.take)(n)},o=function(){return{done:!1,value:l.fork.apply(void 0,[e].concat(u(t),[s]))}},i=function(){return{done:!1,value:(0,l.cancel)(f)}},c=function(){return f?"cancel":"fork"},f=void 0,s=void 0;return a({take:[r,c,function(n){return s=n}],cancel:[i,"fork"],fork:[o,"take",function(n){return f=n}]},"take")}var f=function(){function n(n,e){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=n[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.takeEvery=i,e.takeLatest=c;var s=t(1),l=t(3),d=t(2),v=r(d),p=function(n,e){return s.is.func(n)?n(e):n},g={done:!0}},function(n,e,t){"use strict";function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function u(){var n,e=!0,t=void 0,u=void 0;return n={},r(n,o.TASK,!0),r(n,"isRunning",function(){return e}),r(n,"getResult",function(){return t}),r(n,"getError",function(){return u}),r(n,"setRunning",function(n){return e=n}),r(n,"setResult",function(n){return t=n}),r(n,"setError",function(n){return u=n}),n}Object.defineProperty(e,"__esModule",{value:!0}),e.createMockTask=u;var o=t(1)},function(n,e,t){"use strict";function r(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}var u=t(1),o=t(3),a=t(5),i=t(11),c=t(4),f=r(c);n.exports={TASK:u.TASK,noop:u.noop,is:u.is,asEffect:o.asEffect,deferred:u.deferred,arrayOfDeffered:u.arrayOfDeffered,asap:u.asap,CANCEL:a.CANCEL,RACE_AUTO_CANCEL:a.RACE_AUTO_CANCEL,PARALLEL_AUTO_CANCEL:a.PARALLEL_AUTO_CANCEL,MANUAL_CANCEL:a.MANUAL_CANCEL,createMockTask:i.createMockTask,monitorActions:f}},function(n,e){function t(){f=!1,a.length?c=a.concat(c):s=-1,c.length&&r()}function r(){if(!f){var n=setTimeout(t);f=!0;for(var e=c.length;e;){for(a=c,c=[];++s<e;)a&&a[s].run();s=-1,e=c.length}a=null,f=!1,clearTimeout(n)}}function u(n,e){this.fun=n,this.array=e}function o(){}var a,i=n.exports={},c=[],f=!1,s=-1;i.nextTick=function(n){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];c.push(new u(n,e)),1!==c.length||f||setTimeout(r,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=o,i.addListener=o,i.once=o,i.off=o,i.removeListener=o,i.removeAllListeners=o,i.emit=o,i.binding=function(n){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(n){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}])}); | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReduxSaga=e():n.ReduxSaga=e()}(this,function(){return function(n){function e(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return n[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n,e,t){"use strict";function r(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function u(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.effects=e.takeLatest=e.takeEvery=e.storeIO=e.runSaga=e.isCancelError=e.SagaCancellationException=void 0;var o=t(9);Object.defineProperty(e,"runSaga",{enumerable:!0,get:function(){return o.runSaga}}),Object.defineProperty(e,"storeIO",{enumerable:!0,get:function(){return o.storeIO}});var a=t(10);Object.defineProperty(e,"takeEvery",{enumerable:!0,get:function(){return a.takeEvery}}),Object.defineProperty(e,"takeLatest",{enumerable:!0,get:function(){return a.takeLatest}});var i=t(8),c=u(i),f=t(2),s=u(f),l=t(7),d=r(l),v=t(12),p=r(v);e.default=c.default;var g=e.SagaCancellationException=s.default;e.isCancelError=function(n){return n instanceof g};e.effects=d,e.utils=p},function(n,e,t){(function(n){"use strict";function t(n,e,t){if(!e(n))throw new Error(t)}function r(n,e){var t=n.indexOf(e);t>=0&&n.splice(t,1)}function u(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=c({},n),t=new Promise(function(n,t){e.resolve=n,e.reject=t});return e.promise=t,e}function o(n){for(var e=[],t=0;n>t;t++)e.push(u());return e}function a(){var n=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++n}}function i(n){return Promise.resolve(1).then(function(){return n()})}var c=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.check=t,e.remove=r,e.deferred=u,e.arrayOfDeffered=o,e.autoInc=a,e.asap=i;var f=e.TASK=Symbol("TASK"),s=(e.kTrue=function(){return!0},e.noop=function(){},e.isDev="undefined"!=typeof n&&n.env&&!1,e.is={undef:function(n){return null===n||void 0===n},notUndef:function(n){return null!==n&&void 0!==n},func:function(n){return"function"==typeof n},array:Array.isArray,promise:function(n){return n&&s.func(n.then)},iterator:function(n){return n&&s.func(n.next)&&s.func(n[Symbol.iterator])},"throw":function(n){return n&&s.func(n.throw)},task:function(n){return n&&n[f]}})}).call(e,t(13))},function(n,e){"use strict";function t(n,e,t){var r="SagaCancellationException; type: "+n+", saga: "+e+", origin: "+t;this.name="SagaCancellationException",this.message=r,this.type=n,this.saga=e,this.origin=t,this.stack=(new Error).stack}Object.defineProperty(e,"__esModule",{value:!0}),e.default=t,t.prototype=Object.create(Error.prototype),t.prototype.constructor=t},function(n,e,t){"use strict";function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function u(n){return("*"===n?j.wildcard:m.is.array(n)?j.array:m.is.func(n)?j.predicate:j.default)(n)}function o(n){if(arguments.length>0&&m.is.undef(n))throw new Error(_);return N(R,m.is.undef(n)?"*":n)}function a(n){return N(O,n)}function i(n){return N(b,n)}function c(n,e){(0,m.check)(n,m.is.notUndef,h);var t=null;if(m.is.array(n)){var r=n,u=g(r,2);t=u[0],n=u[1]}else if(n.fn){var o=n;t=o.context,n=o.fn}return(0,m.check)(n,m.is.func,h),{context:t,fn:n,args:e}}function f(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(C,c(n,t))}function s(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return N(C,c({context:n,fn:e},t))}function l(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(T,c(n,t))}function d(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];return N(w,c(n,t))}function v(n){if(!I(n))throw new Error(y);return N(k,n)}function p(n){if(!I(n))throw new Error(E);return N(L,n)}var g=function(){function n(n,e){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=n[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.asEffect=e.INVALID_PATTERN=e.CANCEL_ARG_ERROR=e.JOIN_ARG_ERROR=e.FORK_ARG_ERROR=e.CALL_FUNCTION_ARG_ERROR=void 0,e.matcher=u,e.take=o,e.put=a,e.race=i,e.call=f,e.apply=s,e.cps=l,e.fork=d,e.join=v,e.cancel=p;var m=t(1),h=e.CALL_FUNCTION_ARG_ERROR="call/cps/fork first argument must be a function, an array [context, function] or an object {context, fn}",y=(e.FORK_ARG_ERROR="fork first argument must be a generator function or an iterator",e.JOIN_ARG_ERROR="join argument must be a valid task (a result of a fork)"),E=e.CANCEL_ARG_ERROR="cancel argument must be a valid task (a result of a fork)",_=e.INVALID_PATTERN="Invalid pattern passed to `take` (HINT: check if you didn't mispell a constant)",A=Symbol("IO"),R="TAKE",O="PUT",b="RACE",C="CALL",T="CPS",w="FORK",k="JOIN",L="CANCEL",N=function(n,e){var t;return t={},r(t,A,!0),r(t,n,e),t},j={wildcard:function(){return m.kTrue},"default":function(n){return function(e){return e.type===n}},array:function(n){return function(e){return n.some(function(n){return n===e.type})}},predicate:function(n){return function(e){return n(e)}}},I=function(n){return n[m.TASK]};e.asEffect={take:function(n){return n&&n[A]&&n[R]},put:function(n){return n&&n[A]&&n[O]},race:function(n){return n&&n[A]&&n[b]},call:function(n){return n&&n[A]&&n[C]},cps:function(n){return n&&n[A]&&n[T]},fork:function(n){return n&&n[A]&&n[w]},join:function(n){return n&&n[A]&&n[k]},cancel:function(n){return n&&n[A]&&n[L]}}},function(n,e){"use strict";function t(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n,e,r,u){var o;return o={},t(o,a,!0),t(o,"type",i),t(o,"effectId",n),t(o,"parentEffectId",e),t(o,"label",r),t(o,"effect",u),o}function u(n,e){var r;return r={},t(r,a,!0),t(r,"type",c),t(r,"effectId",n),t(r,"result",e),r}function o(n,e){var r;return r={},t(r,a,!0),t(r,"type",f),t(r,"effectId",n),t(r,"error",e),r}Object.defineProperty(e,"__esModule",{value:!0}),e.effectTriggered=r,e.effectResolved=u,e.effectRejected=o;var a=e.MONITOR_ACTION="MONITOR_ACTION",i=e.EFFECT_TRIGGERED="EFFECT_TRIGGERED",c=e.EFFECT_RESOLVED="EFFECT_RESOLVED",f=e.EFFECT_REJECTED="EFFECT_REJECTED"},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function a(n){function e(u,o){if(!n._isRunning)throw new Error("Trying to resume an already finished generator");try{if(u&&!M)throw u;var a=u?n.throw(u):n.next(o);a.done?t(a.value):r(a.value,I,"",e)}catch(u){if(t(u,!0),!(u instanceof d.default))throw u;i.isDev&&console.warn(S+": uncaught",u)}}function t(e,t){n._isRunning=!1,t?(n._error=e,U.reject(e)):(n._result=e,U.resolve(e)),D()}function r(n,e){function t(n,e){d||(d=!0,o.cancel=i.noop,j(n?s.effectRejected(a,n):s.effectResolved(a,e)),o(n,e))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],o=arguments[3],a=E();j(s.effectTriggered(a,e,r,n));var d=void 0;t.cancel=i.noop,o.cancel=function(n){if(!d){d=!0;try{t.cancel(n)}catch(e){}t.cancel=i.noop,o(n),j(s.effectRejected(a,n))}};var v=void 0;return i.is.promise(n)?u(n,t):i.is.iterator(n)?f(n,a,S,t):i.is.array(n)?T(n,a,t):i.is.notUndef(v=c.asEffect.take(n))?l(v,t):i.is.notUndef(v=c.asEffect.put(n))?_(v,t):i.is.notUndef(v=c.asEffect.race(n))?w(v,a,t):i.is.notUndef(v=c.asEffect.call(n))?A(v,a,t):i.is.notUndef(v=c.asEffect.cps(n))?R(v,t):i.is.notUndef(v=c.asEffect.fork(n))?O(v,a,t):i.is.notUndef(v=c.asEffect.join(n))?b(v,t):i.is.notUndef(v=c.asEffect.cancel(n))?C(v,t):t(null,n)}function u(n,e){var t=n[g];"function"==typeof t&&(e.cancel=t),n.then(function(n){return e(null,n)},function(n){return e(n)})}function f(n,e,t,r){u(a(n,L,N,j,e,t).done,r)}function l(n,e){var t={match:(0,c.matcher)(n),pattern:n,resolve:function(n){return e(null,n)}};P.push(t),e.cancel=function(){return(0,i.remove)(P,t)}}function _(n,e){(0,i.asap)(function(){return e(null,N(n))})}function A(n,e,t){var r=n.context,o=n.fn,a=n.args,c=o.apply(r,a);return i.is.promise(c)?u(c,t):i.is.iterator(c)?f(c,e,o.name,t):t(null,c)}function R(n,e){var t=n.context,r=n.fn,u=n.args;r.apply(t,u.concat(e))}function O(n,e,t){var r=n.context,u=n.fn,o=n.args,c=void 0,f=void 0;c=u.apply(r,o),f=i.is.iterator(c)?c:regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,c;case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},s,this)})(),t(null,a(f,L,N,j,e,u.name,!0))}function b(n,e){u(n.done,e)}function C(n,e){n.done[g](new d.default(y,S,S)),e()}function T(n,e,t){function u(){o===c.length&&(a=!0,t(null,c))}if(!n.length)return void t(null,[]);var o=0,a=void 0,c=Array(n.length),f=n.map(function(n,e){var r=function(n,r){if(!a)if(n){try{t.cancel(new d.default(m,S,S))}catch(n){}t(n)}else c[e]=r,o++,u()};return r.cancel=i.noop,r});t.cancel=function(n){a||(a=!0,f.forEach(function(e){return e.cancel(n)}))},n.forEach(function(n,t){return r(n,e,t,f[t])})}function w(n,e,t){var u=void 0,a=Object.keys(n),c={};a.forEach(function(n){var e=function(e,r){if(!u)if(e){try{t.cancel(new d.default(h,S,S))}catch(e){}t(o({},n,e))}else{try{t.cancel(new d.default(h,S,S))}catch(e){}u=!0,t(null,o({},n,r))}};e.cancel=i.noop,c[n]=e}),t.cancel=function(n){u||(u=!0,a.forEach(function(e){return c[e].cancel(n)}))},a.forEach(function(t){return r(n[t],e,t,c[t])})}function k(n,e,t,r,u){var a;return a={},o(a,i.TASK,!0),o(a,"id",n),o(a,"name",e),o(a,"done",r),o(a,"forked",u),o(a,"cancel",function(n){n instanceof d.default||(n=new d.default(y,e,n)),r[g](n)}),o(a,"isRunning",function(){return t._isRunning}),o(a,"getResult",function(){return t._result}),o(a,"getError",function(){return t._error}),a}var L=arguments.length<=1||void 0===arguments[1]?function(){return i.noop}:arguments[1],N=arguments.length<=2||void 0===arguments[2]?i.noop:arguments[2],j=arguments.length<=3||void 0===arguments[3]?i.noop:arguments[3],I=arguments.length<=4||void 0===arguments[4]?0:arguments[4],S=arguments.length<=5||void 0===arguments[5]?"anonymous":arguments[5];(0,i.check)(n,i.is.iterator,v);var x=p(S),P=[],M=i.is.throw(n),U=(0,i.deferred)(),D=L(function(n){if(void 0===n)throw x;for(var e=0;e<P.length;e++){var t=P[e];t.match(n)&&(P=[],t.resolve(n))}});e.cancel=i.noop;var F=k(I,S,n,U.promise);return F.done[g]=function(n){var t=n.type,r=n.origin;e.cancel(new d.default(t,S,r))},n._isRunning=!0,e(),F}Object.defineProperty(e,"__esModule",{value:!0}),e.MANUAL_CANCEL=e.RACE_AUTO_CANCEL=e.PARALLEL_AUTO_CANCEL=e.CANCEL=e.undefindInputError=e.NOT_ITERATOR_ERROR=void 0,e.default=a;var i=t(1),c=t(3),f=t(4),s=u(f),l=t(2),d=r(l),v=e.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",p=e.undefindInputError=function(n){return"\n "+n+" saga was provided with an undefined input action\n Hints :\n - check that your Action Creator returns a non undefined value\n - if the Saga was started using runSaga, check that your subscribe source provides the action to its listeners\n"},g=e.CANCEL=Symbol("@@redux-saga/cancelPromise"),m=e.PARALLEL_AUTO_CANCEL="PARALLEL_AUTO_CANCEL",h=e.RACE_AUTO_CANCEL="RACE_AUTO_CANCEL",y=e.MANUAL_CANCEL="MANUAL_CANCEL",E=(0,i.autoInc)()},function(n,e,t){"use strict";function r(){function n(n){return t.push(n),function(){return(0,u.remove)(t,n)}}function e(n){t.slice().forEach(function(e){return e(n)})}var t=[];return{subscribe:n,emit:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var u=t(1)},function(n,e,t){"use strict";var r=t(3);n.exports={take:r.take,put:r.put,race:r.race,call:r.call,apply:r.apply,cps:r.cps,fork:r.fork,join:r.join,cancel:r.cancel}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(){function n(n){function e(n){for(var e=arguments.length,t=Array(e>1?e-1:0),u=1;e>u;u++)t[u-1]=arguments[u];return(0,i.default)(n.apply(void 0,[r].concat(t)),c.subscribe,a,l,0,n.name)}var r=n.getState,a=n.dispatch,c=(0,f.default)(),l=o.isDev?function(n){return(0,o.asap)(function(){return a(n)})}:void 0;return u=e,t.forEach(e),function(n){return function(e){var t=n(e);return e[s.MONITOR_ACTION]||c.emit(e),t}}}for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var u=void 0;return n.run=function(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;e>r;r++)t[r-1]=arguments[r];if(!u)throw new Error(v);var o=u.apply(void 0,[n].concat(t));return o.done.catch(function(n){if(!(n instanceof d.default))throw n}),o},n}Object.defineProperty(e,"__esModule",{value:!0}),e.RUN_SAGA_DYNAMIC_ERROR=void 0,e.default=u;var o=t(1),a=t(5),i=r(a),c=t(6),f=r(c),s=t(4),l=t(2),d=r(l),v=e.RUN_SAGA_DYNAMIC_ERROR="Before running a Saga dynamically using middleware.run, you must mount the Saga middleware on the Store using applyMiddleware"},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n){if(a.isDev&&console.warn("storeIO is deprecated, to run Saga dynamically, use 'run' method of the middleware"),n[d])return n[d];var e=(0,s.default)(),t=n.dispatch;return n.dispatch=function(n){var r=t(n);return e.emit(n),r},n[d]={subscribe:e.subscribe,dispatch:n.dispatch},n[d]}function o(n,e){var t=e.subscribe,r=e.dispatch,u=arguments.length<=2||void 0===arguments[2]?a.noop:arguments[2];return(0,a.check)(n,a.is.iterator,l),(0,c.default)(n,t,r,u)}Object.defineProperty(e,"__esModule",{value:!0}),e.NOT_ITERATOR_ERROR=void 0,e.storeIO=u,e.runSaga=o;var a=t(1),i=t(5),c=r(i),f=t(6),s=r(f),l=e.NOT_ITERATOR_ERROR="runSaga must be called on an iterator",d=Symbol("IO")},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function u(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function o(n,e){function t(t,r){if(o)return p;if(r){if(o=!0,!(r instanceof d.default))throw r;return p}a&&a(t);var u=c(n[e],3),i=u[0],f=u[1],s=u[2];return a=s,e=v(f,t),v(i,t)}var r,o=void 0,a=void 0,i=(r={},u(r,Symbol.iterator,function(){return i}),u(r,"next",t),u(r,"throw",function(n){return t(null,n)}),r);return i}function a(n,e){for(var t=arguments.length,r=Array(t>2?t-2:0),u=2;t>u;u++)r[u-2]=arguments[u];var a={done:!1,value:(0,s.take)(n)},i=function(n){return{done:!1,value:s.fork.apply(void 0,[e].concat(r,[n]))}};return o({take:[a,"fork"],fork:[i,"take"]},"take")}function i(n,e){for(var t=arguments.length,r=Array(t>2?t-2:0),u=2;t>u;u++)r[u-2]=arguments[u];var a={done:!1,value:(0,s.take)(n)},i=function(){return{done:!1,value:s.fork.apply(void 0,[e].concat(r,[d]))}},c=function(){return{done:!1,value:(0,s.cancel)(l)}},f=function(){return l?"cancel":"fork"},l=void 0,d=void 0;return o({take:[a,f,function(n){return d=n}],cancel:[c,"fork"],fork:[i,"take",function(n){return l=n}]},"take")}var c=function(){function n(n,e){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=n[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return n(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.takeEvery=a,e.takeLatest=i;var f=t(1),s=t(3),l=t(2),d=r(l),v=function(n,e){return f.is.func(n)?n(e):n},p={done:!0}},function(n,e,t){"use strict";function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function u(){var n,e=!0,t=void 0,u=void 0;return n={},r(n,o.TASK,!0),r(n,"isRunning",function(){return e}),r(n,"getResult",function(){return t}),r(n,"getError",function(){return u}),r(n,"setRunning",function(n){return e=n}),r(n,"setResult",function(n){return t=n}),r(n,"setError",function(n){return u=n}),n}Object.defineProperty(e,"__esModule",{value:!0}),e.createMockTask=u;var o=t(1)},function(n,e,t){"use strict";function r(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}var u=t(1),o=t(3),a=t(5),i=t(11),c=t(4),f=r(c);n.exports={TASK:u.TASK,noop:u.noop,is:u.is,asEffect:o.asEffect,deferred:u.deferred,arrayOfDeffered:u.arrayOfDeffered,asap:u.asap,CANCEL:a.CANCEL,RACE_AUTO_CANCEL:a.RACE_AUTO_CANCEL,PARALLEL_AUTO_CANCEL:a.PARALLEL_AUTO_CANCEL,MANUAL_CANCEL:a.MANUAL_CANCEL,createMockTask:i.createMockTask,monitorActions:f}},function(n,e){function t(){f=!1,a.length?c=a.concat(c):s=-1,c.length&&r()}function r(){if(!f){var n=setTimeout(t);f=!0;for(var e=c.length;e;){for(a=c,c=[];++s<e;)a&&a[s].run();s=-1,e=c.length}a=null,f=!1,clearTimeout(n)}}function u(n,e){this.fun=n,this.array=e}function o(){}var a,i=n.exports={},c=[],f=!1,s=-1;i.nextTick=function(n){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];c.push(new u(n,e)),1!==c.length||f||setTimeout(r,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=o,i.addListener=o,i.once=o,i.off=o,i.removeListener=o,i.removeAllListeners=o,i.emit=o,i.binding=function(n){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(n){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}])}); |
@@ -21,4 +21,2 @@ 'use strict'; | ||
function _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); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -68,7 +66,9 @@ | ||
function takeEvery(pattern, worker) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
var yieldTake = { done: false, value: (0, _io.take)(pattern) }; | ||
var yieldFork = function yieldFork(action) { | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(_toConsumableArray(args), [action])) }; | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [action])) }; | ||
}; | ||
@@ -83,7 +83,9 @@ | ||
function takeLatest(pattern, worker) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
} | ||
var yieldTake = { done: false, value: (0, _io.take)(pattern) }; | ||
var yieldFork = function yieldFork() { | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(_toConsumableArray(args), [currentAction])) }; | ||
return { done: false, value: _io.fork.apply(undefined, [worker].concat(args, [currentAction])) }; | ||
}; | ||
@@ -90,0 +92,0 @@ var yieldCancel = function yieldCancel() { |
{ | ||
"name": "redux-saga", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Saga middleware for Redux to handle Side Effects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
130
README_ja.md
@@ -5,6 +5,6 @@ # redux-saga | ||
もう1つの Redux アプリケーションのための副作用モデル。redux-thunk ミドルウェアによって処理される thunk の代わりに | ||
すべての副作用を伴うロジックを1箇所にまとめる **Saga** を作成します。 | ||
Redux アプリケーションのための「副作用」ミドルウェア(非同期 action)。`redux-thunk` ミドルウェアによって処理される thunk を送り出す代わりに | ||
副作用を伴うすべてのロジックを1箇所にまとめる **Saga** を用意します。 | ||
これはアプリケーションロジックが2箇所に存在することを意味します: | ||
これはアプリケーションロジックが2箇所に存在することを意味しています: | ||
@@ -15,24 +15,18 @@ - Reducer は action ごとの状態遷移を処理する責任を持つ | ||
Saga は Generator 関数を使って作成されます。 | ||
Saga は Generator 関数を使って作成されます。もし馴染みがないようであれば[リンク集](http://yelouafi.github.io/redux-saga/docs/ExternalResources.html)を参考にしてみてください。 | ||
> このドキュメントで見ていくように Generator は ES7 の async 関数より低レイヤーなので、 | ||
async 関数では不可能ではないにせよ実装困難な宣言的な作用とキャンセルのような機能を可能にします。 | ||
thunk とは異なり action creator によるすべての action に関与します。 | ||
Saga が起動するのはアプリケーションの起動時の1回だけです(ただし、Saga の起動によって他の Saga を起動することがあります)。それらはバックグラウンドで実行されるプロセスのように見えます。Saga は store に送り出される action を監視して、その action にもとづいて何をするか決定します: AJAX リクエストのような非同期呼び出しの作成、他の action の送出、 他の Saga の動的な起動など。 | ||
このミドルウェアは以下を提案します: | ||
`redux-saga` では上記のようなタスクを **作用** を生成することによって実現します。作用は Saga によって実行される手順が含まれた単純な JavaScript のオブジェクトです。例えるなら、Redux の action が store によって実行される手順が含まれているオブジェクトであることに似ています。`redux-saga` は非同期関数を呼び出したり、store に action を送り出したり、バックグラウンドのタスクを起動したり、特定の条件を満たす action を待ち受けたり、様々なタスクのために作用を作成する関数を提供します。 | ||
- 構成可能な抽象的な **作用**: action を待って、store に action を送り出して状態の更新を発生させ、 | ||
リモートサービスを呼び出すことはすべて作用の異なる形態です。 | ||
Saga はそれらの作用を慣れ親しんだ制御構造(if, while, for, try/catch)で構成します。 | ||
Generator によって `redux-saga` で非同期コードをシンプルな同期スタイルで書き下すことができます。`async/await` 関数によってできることに似ていますが、Generator は `async` 関数では困難ないくつかのことを可能にします。 | ||
- Saga はそれ自身が作用です。コンビネータを使って他の作用と結合可能です。また他の Saga の内部から呼び出すこともでき、サブルーチンと | ||
[構造化プログラミング](https://ja.wikipedia.org/wiki/%E6%A7%8B%E9%80%A0%E5%8C%96%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0) | ||
の効果を提供します。 | ||
Saga がプレーンなオブジェクトを生成するということは、生成されたオブジェクトを単純に同値チェックすればよいだけになり、Generator のすべてのロジックをテストしやすくします。 | ||
- *[訳注: 意味不明]* 作用は宣言的に生成できます。ミドルウェアに実行させる作用の記述を生成します。 | ||
これにより Generator 内部にある操作のロジックがテスト可能になります。 | ||
さらに `redux-saga` で開始したタスクは手動・自動(他の作用と競争させてたり)を問わずいつでもキャンセル可能です。 | ||
- 複数の action にまたがる複雑な操作を実装できます(例: ログイン後の処理、ウィザードダイアログ、複雑なゲームルール、など)。 | ||
これらは作用を扱う他のミドルウェアでも表現することは簡単ではありません。 | ||
# はじめよう | ||
# インストール | ||
## インストール | ||
@@ -43,2 +37,78 @@ ``` | ||
別の方法として、UMD ビルドを HTML ページの `<script>` タグで直接使うこともできます。詳しくは[こちら](#ブラウザで-umd-ビルドを使用する). | ||
## 使い方 | ||
ボタンがクリックされたらリモートサーバから何らかのユーザデータを取得する UI を考えてみます(簡略化のため、起点となる部分のみ例示します)。 | ||
```javascript | ||
class UserComponent extends React.Component { | ||
... | ||
onSomeButtonClicked() { | ||
const { userId, dispatch } = this.props | ||
dispatch({type: 'USER_FETCH_REQUESTED', payload: {userId}}) | ||
} | ||
... | ||
} | ||
``` | ||
コンポーネントはプレーンオブジェクトの action を store に送り出します。 | ||
`USER_FETCH_REQUESTED` action を監視して、ユーザデータ取得の API 呼び出しを実行する Saga を作ります。 | ||
#### `sagas.js` | ||
```javascript | ||
import { takeEvery, takeLatest } from 'redux-saga' | ||
import { call, put } from 'redux-saga/effects' | ||
import Api from '...' | ||
// Saga ワーカー : USER_FETCH_REQUESTED action によって呼び出される | ||
function* fetchUser(action) { | ||
try { | ||
const user = yield call(Api.fetchUser, action.payload.userId); | ||
yield put({type: "USER_FETCH_SUCCEEDED", user: user}); | ||
} catch (e) { | ||
yield put({type: "USER_FETCH_FAILED",message: e.message}); | ||
} | ||
} | ||
/* | ||
USER_FETCH_REQUESTED action が送出されるたびに fetchUser を開始します。 | ||
ユーザ情報の並列取得にも対応しています。 | ||
*/ | ||
function* mySaga() { | ||
yield* takeEvery("USER_FETCH_REQUESTED", fetchUser); | ||
} | ||
/* | ||
代わりに takeLatest を使うこともできます。 | ||
しかし、ユーザ情報の並列取得には対応しません。 | ||
もしレスポンス待ちの状態で USER_FETCH_REQUESTED を受け取った場合、 | ||
待ち状態のリクエストはキャンセルされて最後の1つだけが実行されます。 | ||
*/ | ||
function* mySaga() { | ||
yield* takeLatest("USER_FETCH_REQUESTED", fetchUser); | ||
} | ||
``` | ||
作成した Saga を実行するには `redux-saga` ミドルウェアを使って Redux の store と接続する必要があります。 | ||
#### `main.js` | ||
```javascript | ||
import { createStore, applyMiddleware } from 'redux' | ||
import createSagaMiddleware from `redux-saga` | ||
import reducer from './reducers' | ||
import mySaga from './sagas' | ||
const sagaMiddleware = createSagaMiddleware(mySaga) | ||
const store = createStore( | ||
reducer, | ||
applyMiddleware(sagaMiddleware) | ||
) | ||
// アプリケーションのレンダリング | ||
``` | ||
# ドキュメント | ||
@@ -92,2 +162,18 @@ | ||
3つのカウンターのサンプルがあります。 | ||
#### counter-vanilla | ||
Vanilla JavaScript と UMD ビルドを使用したデモです。すべてのソースコードは `index.html` にインラインで埋め込まれています。 | ||
単純に `index.html` をブラウザで開くだけでサンプルを実行できます。 | ||
>重要 | ||
ご利用のブラウザが Generator をサポートしている必要があります。 | ||
最新の Chrome / Firefox / MS Edge であれば大丈夫です。 | ||
#### counter | ||
webpack と高レベル API `takeEvery` を使用したデモです。 | ||
``` | ||
@@ -100,2 +186,10 @@ npm run counter | ||
#### cancellable-counter | ||
このデモは低レベル API を使用します。 タスクキャンセルのデモです。 | ||
``` | ||
npm run cancellable-counter | ||
``` | ||
### ショッピングカートのサンプル | ||
@@ -102,0 +196,0 @@ |
@@ -39,3 +39,3 @@ import { is } from './utils' | ||
export function takeEvery(pattern, worker, args = []) { | ||
export function takeEvery(pattern, worker, ...args) { | ||
const yieldTake = { done: false, value: take(pattern)} | ||
@@ -50,3 +50,3 @@ const yieldFork = action => ({ done: false, value: fork(worker, ...args, action)}) | ||
export function takeLatest(pattern, worker, args = []) { | ||
export function takeLatest(pattern, worker, ...args) { | ||
const yieldTake = { done: false, value: take(pattern)} | ||
@@ -53,0 +53,0 @@ const yieldFork = () => ({ done: false, value: fork(worker, ...args, currentAction)}) |
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
211373
2951