redux-saga
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -1295,9 +1295,9 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
(0, _asap2.default)(function () { | ||
var task = proc(_iterator, subscribe, dispatch, getState, monitor, effectId, fn.name, detached ? null : _utils.noop); | ||
if (!detached) { | ||
if (_iterator._isRunning) taskQueue.addTask(task);else if (_iterator._error) return cb(_iterator._error, true); | ||
} | ||
cb(task); | ||
}); | ||
_asap2.default.suspend(); | ||
var task = proc(_iterator, subscribe, dispatch, getState, monitor, effectId, fn.name, detached ? null : _utils.noop); | ||
if (!detached) { | ||
if (_iterator._isRunning) taskQueue.addTask(task);else if (_iterator._error) return cb(_iterator._error, true); | ||
} | ||
cb(task); | ||
_asap2.default.flush(); | ||
// Fork effects are non cancellables | ||
@@ -1304,0 +1304,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ReduxSaga=n():e.ReduxSaga=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";function r(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n.default=e,n}function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.utils=n.effects=n.delay=n.takeLatest=n.takeEvery=n.buffers=n.channel=n.eventChannel=n.END=n.CANCEL=n.runSaga=void 0;var u=t(9);Object.defineProperty(n,"runSaga",{enumerable:!0,get:function(){return u.runSaga}});var a=t(5);Object.defineProperty(n,"CANCEL",{enumerable:!0,get:function(){return a.CANCEL}});var i=t(2);Object.defineProperty(n,"END",{enumerable:!0,get:function(){return i.END}}),Object.defineProperty(n,"eventChannel",{enumerable:!0,get:function(){return i.eventChannel}}),Object.defineProperty(n,"channel",{enumerable:!0,get:function(){return i.channel}});var c=t(4);Object.defineProperty(n,"buffers",{enumerable:!0,get:function(){return c.buffers}});var f=t(10);Object.defineProperty(n,"takeEvery",{enumerable:!0,get:function(){return f.takeEvery}}),Object.defineProperty(n,"takeLatest",{enumerable:!0,get:function(){return f.takeLatest}});var s=t(1);Object.defineProperty(n,"delay",{enumerable:!0,get:function(){return s.delay}});var l=t(8),d=o(l),v=t(6),p=r(v),h=t(11),g=r(h);n.default=d.default,n.effects=p,n.utils=g},function(e,n,t){(function(e){"use strict";function t(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e){return e}function o(e,n,t){if(!n(e))throw new Error(t)}function u(e,n){var t=e.indexOf(n);t>=0&&e.splice(t,1)}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=v({},e),t=new Promise(function(e,t){n.resolve=e,n.reject=t});return n.promise=t,n}function i(e){for(var n=[],t=0;e>t;t++)n.push(a());return n}function c(e){var n=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return new Promise(function(t){return setTimeout(function(){return t(n)},e)})}function f(){var e,n=!0,r=void 0,o=void 0;return e={},t(e,h,!0),t(e,"isRunning",function(){return n}),t(e,"result",function(){return r}),t(e,"error",function(){return o}),t(e,"setRunning",function(e){return n=e}),t(e,"setResult",function(e){return r=e}),t(e,"setError",function(e){return o=e}),e}function s(){var e=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++e}}function l(e){var n=arguments.length<=1||void 0===arguments[1]?b:arguments[1],t=arguments.length<=2||void 0===arguments[2]?"":arguments[2],r={name:t,next:e,"throw":n};return"undefined"!=typeof Symbol&&(r[Symbol.iterator]=function(){return r}),r}function d(e,n,t){"undefined"==typeof window?console.log("redux-saga "+e+": "+n+"\n"+(t&&t.stack||t)):console[e].call(console,n,t)}Object.defineProperty(n,"__esModule",{value:!0});var v=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};n.ident=r,n.check=o,n.remove=u,n.deferred=a,n.arrayOfDeffered=i,n.delay=c,n.createMockTask=f,n.autoInc=s,n.makeIterator=l,n.log=d;var p=n.sym=function(e){return"@@redux-saga/"+e},h=n.TASK=p("TASK"),g=(n.MATCH=p("MATCH"),n.konst=function(e){return function(){return e}}),y=(n.kTrue=g(!0),n.kFalse=g(!1),n.noop=function(){},n.isDev="undefined"!=typeof e&&e.env&&!1,n.is={undef:function(e){return null===e||void 0===e},notUndef:function(e){return null!==e&&void 0!==e},func:function(e){return"function"==typeof e},number:function(e){return"number"==typeof e},array:Array.isArray,promise:function(e){return e&&y.func(e.then)},iterator:function(e){return e&&y.func(e.next)&&y.func(e.throw)},task:function(e){return e&&e[h]},take:function(e){return e&&y.func(e.take)},put:function(e){return e&&y.func(e.put)},observable:function(e){return e&&y.func(e.subscribe)},buffer:function(e){return e&&y.func(e.isEmpty)&&y.func(e.take)&&y.func(e.put)},pattern:function(e){return e&&("string"==typeof e||y.func(e)||y.array(e))}}),b=function(e){throw e};n.internalErr=function(e){return new Error("\n redux-saga: Error checking hooks detected an inconsisten state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project's github repo.\n Error: "+e+"\n")}}).call(n,t(12))},function(e,n,t){"use strict";function r(){function e(e){return t.push(e),function(){return(0,a.remove)(t,e)}}function n(e){for(var n=t.slice(),r=0,o=n.length;o>r;r++)n[r](e)}var t=[];return{subscribe:e,emit:n}}function o(e){function n(){if(u&&l.length)throw(0,a.internalErr)("Can not have a closed channel with pending takers");if(l.length&&!e.isEmpty())throw(0,a.internalErr)("Can not have pedning takers with non empty buffer")}function t(t){if(n(),(0,a.check)(t,a.is.notUndef,s),!u)if(l.length)for(var r=0;r<l.length;r++){var o=l[r];if(!o[a.MATCH]||o[a.MATCH](t))return l.splice(r,1),o(t)}else e.put(t)}function r(t,r){n(),(0,a.check)(t,a.is.func,"channel.take's callback must be a function"),arguments.length>1&&((0,a.check)(r,a.is.func,"channel.take's matcher argument must be a function"),t[a.MATCH]=r),u&&e.isEmpty()?t(c):e.isEmpty()?(l.push(t),t.cancel=function(){return(0,a.remove)(l,t)}):t(e.take())}function o(){if(n(),!u&&(u=!0,l.length)){var e=l;l=[];for(var t=0,r=e.length;r>t;t++)e[t](c);l=[]}}var u=!1,l=[];return arguments.length>0?(0,a.check)(e,a.is.buffer,f):e=i.buffers.fixed(),{take:r,put:t,close:o,get __takers__(){return l},get __closed__(){return u}}}function u(e){var n=arguments.length<=1||void 0===arguments[1]?i.buffers.none():arguments[1],t=arguments[2];arguments.length>2&&(0,a.check)(t,a.is.func,"Invalid match function passed to eventChannel");var r=o(n),u=e(function(e){e===c?r.close():t&&!t(e)||r.put(e)});return{take:r.take,close:function(){r.__closed__||(r.close(),u())}}}Object.defineProperty(n,"__esModule",{value:!0}),n.UNDEFINED_INPUT_ERROR=n.INVALID_BUFFER=n.END=void 0,n.emitter=r,n.channel=o,n.eventChannel=u;var a=t(1),i=t(4),c=n.END={type:"@@redux-saga/CHANNEL_END"},f=n.INVALID_BUFFER="invalid buffer passed to channel factory function",s=n.UNDEFINED_INPUT_ERROR="\n Saga was provided with an undefined 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"},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){if(arguments.length>=2)(0,k.check)(e,k.is.notUndef,"take(channel, pattern): channel is undefined"),(0,k.check)(e,k.is.take,"take(channel, pattern): argument "+e+" is not a valid channel (channel argument must have a take method)"),(0,k.check)(n,k.is.notUndef,"take(channel, pattern): pattern is undefined"),(0,k.check)(n,k.is.pattern,"take(channel, pattern): argument "+n+" is not a valid pattern (pattern must be String | Function: a => boolean | Array<String>)");else if(1===arguments.length)if((0,k.check)(e,k.is.notUndef,"take(patternOrChannel): undefined argument"),k.is.take(e))n="*";else{if(!k.is.pattern(e))throw new Error("take(patternOrChannel): argument "+e+" is not valid channel or a valid pattern");n=e,e=null}else n="*";return x(_,{channel:e,pattern:n})}function u(){var e=o.apply(void 0,arguments);return e[_].maybe=!0,e}function a(e,n){return arguments.length>1?((0,k.check)(e,k.is.notUndef,"put(channel, action): argument channel is undefined"),(0,k.check)(e,k.is.put,"put(channel, action): argument "+e+" is not a valid channel (channel argument must have a put method)"),(0,k.check)(n,k.is.notUndef,"put(channel, action): argument action is undefined")):((0,k.check)(e,k.is.notUndef,"put(action): argument action is undefined"),n=e,e=null),x(j,{channel:e,action:n})}function i(e){return x(O,e)}function c(e,n,t){(0,k.check)(n,k.is.notUndef,e+": argument fn is undefined");var r=null;if(k.is.array(n)){var o=n,u=m(o,2);r=u[0],n=u[1]}else if(n.fn){var a=n;r=a.context,n=a.fn}return(0,k.check)(n,k.is.func,e+": argument "+n+" is not a function"),{context:r,fn:n,args:t}}function f(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return x(w,c("call",e,t))}function s(e,n){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return x(w,c("apply",{context:e,fn:n},t))}function l(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return x(A,c("cps",e,t))}function d(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return x(C,c("fork",e,t))}function v(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];var o=d.apply(void 0,[e].concat(t));return o[C].detached=!0,o}function p(e){if((0,k.check)(e,k.is.notUndef,"join(task): argument task is undefined"),!M(e))throw new Error("join(task): argument "+e+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return x(P,e)}function h(e){if((0,k.check)(e,k.is.notUndef,"cancel(task): argument task is undefined"),!M(e))throw new Error("cancel(task): argument "+e+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return x(T,e)}function g(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return 0===arguments.length?e=k.ident:((0,k.check)(g,k.is.notUndef,"select(selector,[...]): argument selector is undefined"),(0,k.check)(e,k.is.func,"select(selector,[...]): argument "+e+" is not a function")),x(N,{selector:e,args:t})}function y(e,n){return(0,k.check)(e,k.is.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&((0,k.check)(n,k.is.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),(0,k.check)(n,k.is.notUndef,"actionChannel(pattern, buffer): argument "+n+" is not a valid buffer")),x(S,{pattern:e,buffer:n})}function b(){return x(R,{})}Object.defineProperty(n,"__esModule",{value:!0}),n.asEffect=void 0;var m=function(){function e(e,n){var t=[],r=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(c){o=!0,u=c}finally{try{!r&&i.return&&i.return()}finally{if(o)throw u}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.take=o,n.takem=u,n.put=a,n.race=i,n.call=f,n.apply=s,n.cps=l,n.fork=d,n.spawn=v,n.join=p,n.cancel=h,n.select=g,n.actionChannel=y,n.cancelled=b;var k=t(1),E=(0,k.sym)("IO"),_="TAKE",j="PUT",O="RACE",w="CALL",A="CPS",C="FORK",P="JOIN",T="CANCEL",N="SELECT",S="ACTION_CHANNEL",R="CANCELLED",x=function(e,n){var t;return t={},r(t,E,!0),r(t,e,n),t},M=function(e){return e[k.TASK]};n.asEffect={take:function(e){return e&&e[E]&&e[_]},put:function(e){return e&&e[E]&&e[j]},race:function(e){return e&&e[E]&&e[O]},call:function(e){return e&&e[E]&&e[w]},cps:function(e){return e&&e[E]&&e[A]},fork:function(e){return e&&e[E]&&e[C]},join:function(e){return e&&e[E]&&e[P]},cancel:function(e){return e&&e[E]&&e[T]},select:function(e){return e&&e[E]&&e[N]},actionChannel:function(e){return e&&e[E]&&e[S]},cancelled:function(e){return e&&e[E]&&e[R]}}},function(e,n,t){"use strict";function r(){var e=arguments.length<=0||void 0===arguments[0]?1/0:arguments[0],n=arguments[1],t=[];return{isEmpty:function(){return!t.length},put:function(r){if(t.length<e)t.push(r);else switch(n){case a:throw new Error(u);case c:t.shift(),t.push(r)}},take:function(){return t.shift()}}}Object.defineProperty(n,"__esModule",{value:!0}),n.buffers=n.BUFFER_OVERFLOW=void 0;var o=t(1),u=n.BUFFER_OVERFLOW="Channel's Buffer overflow!",a=1,i=2,c=3,f={isEmpty:o.kTrue,put:o.noop,take:o.noop};n.buffers={none:function(){return f},fixed:function(e){return r(e,a)},dropping:function(e){return r(e,i)},sliding:function(e){return r(e,c)}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,n){for(var t in n){var r=n[t];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t,r)}return e}function u(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return("*"===e?E.wildcard:s.is.array(e)?E.array:s.is.func(e)?E.predicate:E.default)(e)}function c(e,n,t){function r(e){u.push(e),e.cont=function(r,c){i||((0,s.remove)(u,e),e.cont=s.noop,c?(o(),t(r,!0)):(e===n&&(a=r),u.length||(i=!0,t(a))))}}function o(){i||(i=!0,u.forEach(function(e){e.cont=s.noop,e.cancel()}),u=[])}var u=[],a=void 0,i=!1;return r(n),{addTask:r,cancelAll:o,getTasks:function(){return u},taskNames:function(){return u.map(function(e){return e.name})}}}function f(e){function n(){Y.isRunning&&!Y.isCancelled&&(Y.isCancelled=!0,r(k))}function t(){e._isRunning&&!e._isCancelled&&(e._isCancelled=!0,G.cancelAll(),l(k))}function r(n,t){if(!Y.isRunning)throw new Error("Trying to resume an already finished generator");try{var o=void 0;t?o=e.throw(n):n===k?(Y.isCancelled=!0,r.cancel(),o=s.is.func(e.return)?e.return(k):{done:!0,value:k}):o=n===m?s.is.func(e.return)?e.return():{done:!0}:e.next(n),o.done?(Y.isMainRunning=!1,Y.cont&&Y.cont(o.value)):E(o.value,H,"",r)}catch(u){Y.isCancelled&&(0,s.log)("error","uncaught at "+K,u.message),Y.isMainRunning=!1,Y.cont(u,!0)}}function l(n,t){e._isRunning=!1,V.close(),t?(n instanceof Error&&(n.sagaStack="at "+K+" \n "+(n.sagaStack||n.message)),W.cont||(0,s.log)("error","uncaught",n.sagaStack||n.message),e._error=n,e._isAborted=!0,e._deferredEnd&&e._deferredEnd.reject(n)):(n===k&&s.isDev&&(0,s.log)("info",K+" has been cancelled",""),e._result=n,e._deferredEnd&&e._deferredEnd.resolve(n)),W.cont&&W.cont(n,t),W.joiners.forEach(function(e){return e.cb(n,t)}),W.joiners=null}function E(e,n){function t(e,n){a||(a=!0,o.cancel=s.noop,q&&(n?q.effectRejected(u,e):q.effectResolved(u,e)),o(e,n))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],o=arguments[3],u=b();q&&q.effectTriggered({effectId:u,parentEffectId:n,label:r,effect:e});var a=void 0;t.cancel=s.noop,o.cancel=function(){if(!a){a=!0;try{t.cancel()}catch(e){(0,s.log)("error","uncaught at "+K,e.message)}t.cancel=s.noop,q&&q.effectCancelled(u)}};var i=void 0;return s.is.promise(e)?_(e,t):s.is.iterator(e)?j(e,u,K,t):s.is.array(e)?S(e,u,t):s.is.notUndef(i=v.asEffect.take(e))?O(i,t):s.is.notUndef(i=v.asEffect.put(e))?w(i,t):s.is.notUndef(i=v.asEffect.race(e))?R(i,u,t):s.is.notUndef(i=v.asEffect.call(e))?A(i,u,t):s.is.notUndef(i=v.asEffect.cps(e))?C(i,t):s.is.notUndef(i=v.asEffect.fork(e))?P(i,u,t):s.is.notUndef(i=v.asEffect.join(e))?T(i,t):s.is.notUndef(i=v.asEffect.cancel(e))?N(i,t):s.is.notUndef(i=v.asEffect.select(e))?x(i,t):s.is.notUndef(i=v.asEffect.actionChannel(e))?M(i,t):s.is.notUndef(i=v.asEffect.cancelled(e))?U(i,t):t(e)}function _(e,n){var t=e[y];"function"==typeof t&&(n.cancel=t),e.then(n,function(e){return n(e,!0)})}function j(e,n,t,r){f(e,D,I,F,q,n,t,r)}function O(e,n){var t=e.channel,r=e.pattern,o=e.maybe;t=t||V;var u=function(e){return e instanceof Error?n(e,!0):n(e!==p.END||o?e:m)};try{t.take(u,i(r))}catch(a){return n(a,!0)}n.cancel=u.cancel}function w(e,n){var t=e.channel,r=e.action;(0,d.default)(function(){var e=void 0;try{e=(t?t.put:I)(r)}catch(o){return n(o,!0)}return s.is.promise(e)?void _(e,n):n(e)})}function A(e,n,t){var r=e.context,o=e.fn,u=e.args,a=void 0;try{a=o.apply(r,u)}catch(i){return t(i,!0)}return s.is.promise(a)?_(a,t):s.is.iterator(a)?j(a,n,o.name,t):t(a)}function C(e,n){var t=e.context,r=e.fn,o=e.args;try{r.apply(t,o.concat(function(e,t){return s.is.undef(e)?n(t):n(e,!0)}))}catch(u){return n(u,!0)}}function P(e,n,t){var r=e.context,o=e.fn,u=e.args,a=e.detached,i=void 0,c=void 0,l=void 0;try{i=o.apply(r,u)}catch(v){if(!a)return t(v);c=v}l=s.is.iterator(i)?i:c?(0,s.makeIterator)(function(){throw c}):(0,s.makeIterator)(function(){var e=void 0,n={done:!1,value:i},t=function(e){return{done:!0,value:e}};return function(r){return e?t(r):(e=!0,n)}}()),(0,d.default)(function(){var e=f(l,D,I,F,q,n,o.name,a?null:s.noop);if(!a)if(l._isRunning)G.addTask(e);else if(l._error)return t(l._error,!0);t(e)})}function T(e,n){e.isRunning()?!function(){var t={task:W,cb:n};n.cancel=function(){return(0,s.remove)(e.joiners,t)},e.joiners.push(t)}():e.isAborted()?n(e.error(),!0):n(e.result())}function N(e,n){e.isRunning()&&e.cancel(),n()}function S(e,n,t){function r(){o===a.length&&(u=!0,t(a))}if(!e.length)return t([]);var o=0,u=void 0,a=Array(e.length),i=e.map(function(e,n){var i=function(e,i){u||(i||e===p.END||e===m||e===k?(t.cancel(),t(e,i)):(a[n]=e,o++,r()))};return i.cancel=s.noop,i});t.cancel=function(){u||(u=!0,i.forEach(function(e){return e.cancel()}))},e.forEach(function(e,t){return E(e,n,t,i[t])})}function R(e,n,t){var r=void 0,o=Object.keys(e),u={};o.forEach(function(e){var n=function(n,o){r||(o?(t.cancel(),t(n,!0)):n!==p.END&&n!==m&&n!==k&&(t.cancel(),r=!0,t(a({},e,n))))};n.cancel=s.noop,u[e]=n}),t.cancel=function(){r||(r=!0,o.forEach(function(e){return u[e].cancel()}))},o.forEach(function(t){return E(e[t],n,t,u[t])})}function x(e,n){var t=e.selector,r=e.args;try{var o=t.apply(void 0,[F()].concat(u(r)));n(o)}catch(a){n(a,!0)}}function M(e,n){var t=e.pattern,r=e.buffer,o=i(t);o.pattern=t,n((0,p.eventChannel)(D,r||h.buffers.fixed(),o))}function U(e,n){n(!!Y.isCancelled)}function L(e,n,r,u){var i,c,f;return r._deferredEnd=null,c={},a(c,s.TASK,!0),a(c,"id",e),a(c,"name",n),i="done",f={},f[i]=f[i]||{},f[i].get=function(){if(r._deferredEnd)return r._deferredEnd.promise;var e=(0,s.deferred)();return r._deferredEnd=e,r._isRunning||(r._error?e.reject(r._error):e.resolve(r._result)),e.promise},a(c,"cont",u),a(c,"joiners",[]),a(c,"cancel",t),a(c,"isRunning",function(){return r._isRunning}),a(c,"isCancelled",function(){return r._isCancelled}),a(c,"isAborted",function(){return r._isAborted}),a(c,"result",function(){return r._result}),a(c,"error",function(){return r._error}),o(c,f),c}var D=arguments.length<=1||void 0===arguments[1]?function(){return s.noop}:arguments[1],I=arguments.length<=2||void 0===arguments[2]?s.noop:arguments[2],F=arguments.length<=3||void 0===arguments[3]?s.noop:arguments[3],q=arguments[4],H=arguments.length<=5||void 0===arguments[5]?0:arguments[5],K=arguments.length<=6||void 0===arguments[6]?"anonymous":arguments[6],B=arguments[7];(0,s.check)(e,s.is.iterator,g);var V=(0,p.eventChannel)(D);r.cancel=s.noop;var W=L(H,K,e,B),Y={name:K,cancel:n,isRunning:!0},G=c(K,Y,l);return B&&(B.cancel=t),e._isRunning=!0,r(),W}Object.defineProperty(n,"__esModule",{value:!0}),n.TASK_CANCEL=n.CHANNEL_END=n.CANCEL=n.NOT_ITERATOR_ERROR=void 0,n.default=f;var s=t(1),l=t(7),d=r(l),v=t(3),p=t(2),h=t(4),g=n.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",y=n.CANCEL=(0,s.sym)("cancelPromise"),b=(0,s.autoInc)(),m=n.CHANNEL_END={toString:function(){return"@@redux-saga/CHANNEL_END"}},k=n.TASK_CANCEL={toString:function(){return"@@redux-saga/TASK_CANCEL"}},E={wildcard:function(){return s.kTrue},"default":function(e){return function(n){return n.type===e}},array:function(e){return function(n){return e.some(function(e){return e===n.type})}},predicate:function(e){return function(n){return e(n)}}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(3);Object.defineProperty(n,"take",{enumerable:!0,get:function(){return r.take}}),Object.defineProperty(n,"takem",{enumerable:!0,get:function(){return r.takem}}),Object.defineProperty(n,"put",{enumerable:!0,get:function(){return r.put}}),Object.defineProperty(n,"race",{enumerable:!0,get:function(){return r.race}}),Object.defineProperty(n,"call",{enumerable:!0,get:function(){return r.call}}),Object.defineProperty(n,"apply",{enumerable:!0,get:function(){return r.apply}}),Object.defineProperty(n,"cps",{enumerable:!0,get:function(){return r.cps}}),Object.defineProperty(n,"fork",{enumerable:!0,get:function(){return r.fork}}),Object.defineProperty(n,"spawn",{enumerable:!0,get:function(){return r.spawn}}),Object.defineProperty(n,"join",{enumerable:!0,get:function(){return r.join}}),Object.defineProperty(n,"cancel",{enumerable:!0,get:function(){return r.cancel}}),Object.defineProperty(n,"select",{enumerable:!0,get:function(){return r.select}}),Object.defineProperty(n,"actionChannel",{enumerable:!0,get:function(){return r.actionChannel}}),Object.defineProperty(n,"cancelled",{enumerable:!0,get:function(){return r.cancelled}})},function(e,n){"use strict";function t(e){o?r.push(e):(o=!0,r.push(e),t.flush())}Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;var r=[],o=!1;t.suspend=function(){return o=!0},t.flush=function(){for(var e=void 0;e=r.shift();)e();o=!1}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){function e(e){function r(e){for(var t=arguments.length,r=Array(t>1?t-1:0),c=1;t>c;c++)r[c-1]=arguments[c];return(0,i.default)(e.apply(void 0,r),a.subscribe,u,o,n.sagaMonitor,0,e.name)}var o=e.getState,u=e.dispatch;t=r;var a=(0,c.emitter)();return function(e){return function(n){var t=e(n);return a.emit(n),t}}}var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=void 0;if(u.is.func(n))throw new Error("You passed a function to the Saga middleware. You are likely trying to start a Saga by directly passing it to the middleware. This is no longer possible starting from 0.10.0. To run a Saga, you must do it dynamically AFTER mounting the middleware into the store.\n Example:\n import createSagaMiddleware from 'redux-saga'\n ... other imports\n\n const sagaMiddleware = createSagaMiddleware()\n const store = createStore(reducer, applyMiddleware(sagaMiddleware))\n sagaMiddleware.run(saga, ...args)\n ");return e.run=function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;n>o;o++)r[o-1]=arguments[o];return(0,u.check)(t,u.is.notUndef,"Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware"),(0,u.check)(e,u.is.func,"sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!"),t.apply(void 0,[e].concat(r))},e}Object.defineProperty(n,"__esModule",{value:!0}),n.default=o;var u=t(1),a=t(5),i=r(a),c=t(2)},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,n,t){var r=n.subscribe,o=n.dispatch,a=n.getState;return(0,u.check)(e,u.is.iterator,"runSaga must be called on an iterator"),(0,i.default)(e,r,o,a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.runSaga=o;var u=t(1),a=t(5),i=r(a)},function(e,n,t){"use strict";function r(e,n){function t(n,t){if(u===l)return s;if(t)throw u=l,t;o&&o(n);var r=e[u](),i=a(r,3),c=i[0],f=i[1],d=i[2];return u=c,o=d,u===l?s:f}var r=arguments.length<=2||void 0===arguments[2]?"iterator":arguments[2],o=void 0,u=n;return(0,c.makeIterator)(t,function(e){return t(null,e)},r)}function o(e,n){for(var t=arguments.length,o=Array(t>2?t-2:0),u=2;t>u;u++)o[u-2]=arguments[u];var a={done:!1,value:(0,f.take)(e)},c=function(e){return{done:!1,value:f.fork.apply(void 0,[n].concat(o,[e]))}},s=void 0,d=function(e){return s=e};return r({q1:function(){return["q2",a,d]},q2:function(){return s===i.END?[l]:["q1",c(s)]}},"q1","takeEvery("+String(e)+", "+n.name+")")}function u(e,n){for(var t=arguments.length,o=Array(t>2?t-2:0),u=2;t>u;u++)o[u-2]=arguments[u];var a={done:!1,value:(0,f.take)(e)},c=function(e){return{done:!1,value:f.fork.apply(void 0,[n].concat(o,[e]))}},s=function(e){return{done:!1,value:(0,f.cancel)(e)}},d=void 0,v=void 0,p=function(e){return d=e},h=function(e){return v=e};return r({q1:function(){return["q2",a,h]},q2:function(){return v===i.END?[l]:d?["q3",s(d)]:["q1",c(v),p]},q3:function(){return["q1",c(v),p]}},"q1","takeLatest("+String(e)+", "+n.name+")")}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,n){var t=[],r=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(c){o=!0,u=c}finally{try{!r&&i.return&&i.return()}finally{if(o)throw u}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.takeEvery=o,n.takeLatest=u;var i=t(2),c=t(1),f=t(3),s={done:!0,value:void 0},l={}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(1);Object.defineProperty(n,"TASK",{enumerable:!0,get:function(){return r.TASK}}),Object.defineProperty(n,"noop",{enumerable:!0,get:function(){return r.noop}}),Object.defineProperty(n,"is",{enumerable:!0,get:function(){return r.is}}),Object.defineProperty(n,"deferred",{enumerable:!0,get:function(){return r.deferred}}),Object.defineProperty(n,"arrayOfDeffered",{enumerable:!0,get:function(){return r.arrayOfDeffered}}),Object.defineProperty(n,"createMockTask",{enumerable:!0,get:function(){return r.createMockTask}});var o=t(3);Object.defineProperty(n,"asEffect",{enumerable:!0,get:function(){return o.asEffect}})},function(e,n){function t(){f=!1,a.length?c=a.concat(c):s=-1,c.length&&r()}function r(){if(!f){var e=setTimeout(t);f=!0;for(var n=c.length;n;){for(a=c,c=[];++s<n;)a&&a[s].run();s=-1,n=c.length}a=null,f=!1,clearTimeout(e)}}function o(e,n){this.fun=e,this.array=n}function u(){}var a,i=e.exports={},c=[],f=!1,s=-1;i.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];c.push(new o(e,n)),1!==c.length||f||setTimeout(r,0)},o.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=u,i.addListener=u,i.once=u,i.off=u,i.removeListener=u,i.removeAllListeners=u,i.emit=u,i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}])}); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ReduxSaga=n():e.ReduxSaga=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var u=t[r]={exports:{},id:r,loaded:!1};return e[r].call(u.exports,u,u.exports,n),u.loaded=!0,u.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";function r(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n.default=e,n}function u(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0}),n.utils=n.effects=n.delay=n.takeLatest=n.takeEvery=n.buffers=n.channel=n.eventChannel=n.END=n.CANCEL=n.runSaga=void 0;var o=t(9);Object.defineProperty(n,"runSaga",{enumerable:!0,get:function(){return o.runSaga}});var a=t(5);Object.defineProperty(n,"CANCEL",{enumerable:!0,get:function(){return a.CANCEL}});var i=t(2);Object.defineProperty(n,"END",{enumerable:!0,get:function(){return i.END}}),Object.defineProperty(n,"eventChannel",{enumerable:!0,get:function(){return i.eventChannel}}),Object.defineProperty(n,"channel",{enumerable:!0,get:function(){return i.channel}});var c=t(4);Object.defineProperty(n,"buffers",{enumerable:!0,get:function(){return c.buffers}});var f=t(10);Object.defineProperty(n,"takeEvery",{enumerable:!0,get:function(){return f.takeEvery}}),Object.defineProperty(n,"takeLatest",{enumerable:!0,get:function(){return f.takeLatest}});var s=t(1);Object.defineProperty(n,"delay",{enumerable:!0,get:function(){return s.delay}});var l=t(8),d=u(l),p=t(6),v=r(p),h=t(11),g=r(h);n.default=d.default,n.effects=v,n.utils=g},function(e,n,t){(function(e){"use strict";function t(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e){return e}function u(e,n,t){if(!n(e))throw new Error(t)}function o(e,n){var t=e.indexOf(n);t>=0&&e.splice(t,1)}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=p({},e),t=new Promise(function(e,t){n.resolve=e,n.reject=t});return n.promise=t,n}function i(e){for(var n=[],t=0;e>t;t++)n.push(a());return n}function c(e){var n=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return new Promise(function(t){return setTimeout(function(){return t(n)},e)})}function f(){var e,n=!0,r=void 0,u=void 0;return e={},t(e,h,!0),t(e,"isRunning",function(){return n}),t(e,"result",function(){return r}),t(e,"error",function(){return u}),t(e,"setRunning",function(e){return n=e}),t(e,"setResult",function(e){return r=e}),t(e,"setError",function(e){return u=e}),e}function s(){var e=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++e}}function l(e){var n=arguments.length<=1||void 0===arguments[1]?b:arguments[1],t=arguments.length<=2||void 0===arguments[2]?"":arguments[2],r={name:t,next:e,"throw":n};return"undefined"!=typeof Symbol&&(r[Symbol.iterator]=function(){return r}),r}function d(e,n,t){"undefined"==typeof window?console.log("redux-saga "+e+": "+n+"\n"+(t&&t.stack||t)):console[e].call(console,n,t)}Object.defineProperty(n,"__esModule",{value:!0});var p=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};n.ident=r,n.check=u,n.remove=o,n.deferred=a,n.arrayOfDeffered=i,n.delay=c,n.createMockTask=f,n.autoInc=s,n.makeIterator=l,n.log=d;var v=n.sym=function(e){return"@@redux-saga/"+e},h=n.TASK=v("TASK"),g=(n.MATCH=v("MATCH"),n.konst=function(e){return function(){return e}}),y=(n.kTrue=g(!0),n.kFalse=g(!1),n.noop=function(){},n.isDev="undefined"!=typeof e&&e.env&&!1,n.is={undef:function(e){return null===e||void 0===e},notUndef:function(e){return null!==e&&void 0!==e},func:function(e){return"function"==typeof e},number:function(e){return"number"==typeof e},array:Array.isArray,promise:function(e){return e&&y.func(e.then)},iterator:function(e){return e&&y.func(e.next)&&y.func(e.throw)},task:function(e){return e&&e[h]},take:function(e){return e&&y.func(e.take)},put:function(e){return e&&y.func(e.put)},observable:function(e){return e&&y.func(e.subscribe)},buffer:function(e){return e&&y.func(e.isEmpty)&&y.func(e.take)&&y.func(e.put)},pattern:function(e){return e&&("string"==typeof e||y.func(e)||y.array(e))}}),b=function(e){throw e};n.internalErr=function(e){return new Error("\n redux-saga: Error checking hooks detected an inconsisten state. This is likely a bug\n in redux-saga code and not yours. Thanks for reporting this in the project's github repo.\n Error: "+e+"\n")}}).call(n,t(12))},function(e,n,t){"use strict";function r(){function e(e){return t.push(e),function(){return(0,a.remove)(t,e)}}function n(e){for(var n=t.slice(),r=0,u=n.length;u>r;r++)n[r](e)}var t=[];return{subscribe:e,emit:n}}function u(e){function n(){if(o&&l.length)throw(0,a.internalErr)("Can not have a closed channel with pending takers");if(l.length&&!e.isEmpty())throw(0,a.internalErr)("Can not have pedning takers with non empty buffer")}function t(t){if(n(),(0,a.check)(t,a.is.notUndef,s),!o)if(l.length)for(var r=0;r<l.length;r++){var u=l[r];if(!u[a.MATCH]||u[a.MATCH](t))return l.splice(r,1),u(t)}else e.put(t)}function r(t,r){n(),(0,a.check)(t,a.is.func,"channel.take's callback must be a function"),arguments.length>1&&((0,a.check)(r,a.is.func,"channel.take's matcher argument must be a function"),t[a.MATCH]=r),o&&e.isEmpty()?t(c):e.isEmpty()?(l.push(t),t.cancel=function(){return(0,a.remove)(l,t)}):t(e.take())}function u(){if(n(),!o&&(o=!0,l.length)){var e=l;l=[];for(var t=0,r=e.length;r>t;t++)e[t](c);l=[]}}var o=!1,l=[];return arguments.length>0?(0,a.check)(e,a.is.buffer,f):e=i.buffers.fixed(),{take:r,put:t,close:u,get __takers__(){return l},get __closed__(){return o}}}function o(e){var n=arguments.length<=1||void 0===arguments[1]?i.buffers.none():arguments[1],t=arguments[2];arguments.length>2&&(0,a.check)(t,a.is.func,"Invalid match function passed to eventChannel");var r=u(n),o=e(function(e){e===c?r.close():t&&!t(e)||r.put(e)});return{take:r.take,close:function(){r.__closed__||(r.close(),o())}}}Object.defineProperty(n,"__esModule",{value:!0}),n.UNDEFINED_INPUT_ERROR=n.INVALID_BUFFER=n.END=void 0,n.emitter=r,n.channel=u,n.eventChannel=o;var a=t(1),i=t(4),c=n.END={type:"@@redux-saga/CHANNEL_END"},f=n.INVALID_BUFFER="invalid buffer passed to channel factory function",s=n.UNDEFINED_INPUT_ERROR="\n Saga was provided with an undefined 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"},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function u(e,n){if(arguments.length>=2)(0,k.check)(e,k.is.notUndef,"take(channel, pattern): channel is undefined"),(0,k.check)(e,k.is.take,"take(channel, pattern): argument "+e+" is not a valid channel (channel argument must have a take method)"),(0,k.check)(n,k.is.notUndef,"take(channel, pattern): pattern is undefined"),(0,k.check)(n,k.is.pattern,"take(channel, pattern): argument "+n+" is not a valid pattern (pattern must be String | Function: a => boolean | Array<String>)");else if(1===arguments.length)if((0,k.check)(e,k.is.notUndef,"take(patternOrChannel): undefined argument"),k.is.take(e))n="*";else{if(!k.is.pattern(e))throw new Error("take(patternOrChannel): argument "+e+" is not valid channel or a valid pattern");n=e,e=null}else n="*";return x(_,{channel:e,pattern:n})}function o(){var e=u.apply(void 0,arguments);return e[_].maybe=!0,e}function a(e,n){return arguments.length>1?((0,k.check)(e,k.is.notUndef,"put(channel, action): argument channel is undefined"),(0,k.check)(e,k.is.put,"put(channel, action): argument "+e+" is not a valid channel (channel argument must have a put method)"),(0,k.check)(n,k.is.notUndef,"put(channel, action): argument action is undefined")):((0,k.check)(e,k.is.notUndef,"put(action): argument action is undefined"),n=e,e=null),x(j,{channel:e,action:n})}function i(e){return x(O,e)}function c(e,n,t){(0,k.check)(n,k.is.notUndef,e+": argument fn is undefined");var r=null;if(k.is.array(n)){var u=n,o=m(u,2);r=o[0],n=o[1]}else if(n.fn){var a=n;r=a.context,n=a.fn}return(0,k.check)(n,k.is.func,e+": argument "+n+" is not a function"),{context:r,fn:n,args:t}}function f(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return x(w,c("call",e,t))}function s(e,n){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return x(w,c("apply",{context:e,fn:n},t))}function l(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return x(A,c("cps",e,t))}function d(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return x(C,c("fork",e,t))}function p(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];var u=d.apply(void 0,[e].concat(t));return u[C].detached=!0,u}function v(e){if((0,k.check)(e,k.is.notUndef,"join(task): argument task is undefined"),!M(e))throw new Error("join(task): argument "+e+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return x(P,e)}function h(e){if((0,k.check)(e,k.is.notUndef,"cancel(task): argument task is undefined"),!M(e))throw new Error("cancel(task): argument "+e+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return x(T,e)}function g(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return 0===arguments.length?e=k.ident:((0,k.check)(g,k.is.notUndef,"select(selector,[...]): argument selector is undefined"),(0,k.check)(e,k.is.func,"select(selector,[...]): argument "+e+" is not a function")),x(N,{selector:e,args:t})}function y(e,n){return(0,k.check)(e,k.is.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&((0,k.check)(n,k.is.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),(0,k.check)(n,k.is.notUndef,"actionChannel(pattern, buffer): argument "+n+" is not a valid buffer")),x(S,{pattern:e,buffer:n})}function b(){return x(R,{})}Object.defineProperty(n,"__esModule",{value:!0}),n.asEffect=void 0;var m=function(){function e(e,n){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.take=u,n.takem=o,n.put=a,n.race=i,n.call=f,n.apply=s,n.cps=l,n.fork=d,n.spawn=p,n.join=v,n.cancel=h,n.select=g,n.actionChannel=y,n.cancelled=b;var k=t(1),E=(0,k.sym)("IO"),_="TAKE",j="PUT",O="RACE",w="CALL",A="CPS",C="FORK",P="JOIN",T="CANCEL",N="SELECT",S="ACTION_CHANNEL",R="CANCELLED",x=function(e,n){var t;return t={},r(t,E,!0),r(t,e,n),t},M=function(e){return e[k.TASK]};n.asEffect={take:function(e){return e&&e[E]&&e[_]},put:function(e){return e&&e[E]&&e[j]},race:function(e){return e&&e[E]&&e[O]},call:function(e){return e&&e[E]&&e[w]},cps:function(e){return e&&e[E]&&e[A]},fork:function(e){return e&&e[E]&&e[C]},join:function(e){return e&&e[E]&&e[P]},cancel:function(e){return e&&e[E]&&e[T]},select:function(e){return e&&e[E]&&e[N]},actionChannel:function(e){return e&&e[E]&&e[S]},cancelled:function(e){return e&&e[E]&&e[R]}}},function(e,n,t){"use strict";function r(){var e=arguments.length<=0||void 0===arguments[0]?1/0:arguments[0],n=arguments[1],t=[];return{isEmpty:function(){return!t.length},put:function(r){if(t.length<e)t.push(r);else switch(n){case a:throw new Error(o);case c:t.shift(),t.push(r)}},take:function(){return t.shift()}}}Object.defineProperty(n,"__esModule",{value:!0}),n.buffers=n.BUFFER_OVERFLOW=void 0;var u=t(1),o=n.BUFFER_OVERFLOW="Channel's Buffer overflow!",a=1,i=2,c=3,f={isEmpty:u.kTrue,put:u.noop,take:u.noop};n.buffers={none:function(){return f},fixed:function(e){return r(e,a)},dropping:function(e){return r(e,i)},sliding:function(e){return r(e,c)}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,n){for(var t in n){var r=n[t];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t,r)}return e}function o(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){return("*"===e?E.wildcard:s.is.array(e)?E.array:s.is.func(e)?E.predicate:E.default)(e)}function c(e,n,t){function r(e){o.push(e),e.cont=function(r,c){i||((0,s.remove)(o,e),e.cont=s.noop,c?(u(),t(r,!0)):(e===n&&(a=r),o.length||(i=!0,t(a))))}}function u(){i||(i=!0,o.forEach(function(e){e.cont=s.noop,e.cancel()}),o=[])}var o=[],a=void 0,i=!1;return r(n),{addTask:r,cancelAll:u,getTasks:function(){return o},taskNames:function(){return o.map(function(e){return e.name})}}}function f(e){function n(){Y.isRunning&&!Y.isCancelled&&(Y.isCancelled=!0,r(k))}function t(){e._isRunning&&!e._isCancelled&&(e._isCancelled=!0,G.cancelAll(),l(k))}function r(n,t){if(!Y.isRunning)throw new Error("Trying to resume an already finished generator");try{var u=void 0;t?u=e.throw(n):n===k?(Y.isCancelled=!0,r.cancel(),u=s.is.func(e.return)?e.return(k):{done:!0,value:k}):u=n===m?s.is.func(e.return)?e.return():{done:!0}:e.next(n),u.done?(Y.isMainRunning=!1,Y.cont&&Y.cont(u.value)):E(u.value,H,"",r)}catch(o){Y.isCancelled&&(0,s.log)("error","uncaught at "+K,o.message),Y.isMainRunning=!1,Y.cont(o,!0)}}function l(n,t){e._isRunning=!1,V.close(),t?(n instanceof Error&&(n.sagaStack="at "+K+" \n "+(n.sagaStack||n.message)),W.cont||(0,s.log)("error","uncaught",n.sagaStack||n.message),e._error=n,e._isAborted=!0,e._deferredEnd&&e._deferredEnd.reject(n)):(n===k&&s.isDev&&(0,s.log)("info",K+" has been cancelled",""),e._result=n,e._deferredEnd&&e._deferredEnd.resolve(n)),W.cont&&W.cont(n,t),W.joiners.forEach(function(e){return e.cb(n,t)}),W.joiners=null}function E(e,n){function t(e,n){a||(a=!0,u.cancel=s.noop,q&&(n?q.effectRejected(o,e):q.effectResolved(o,e)),u(e,n))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],u=arguments[3],o=b();q&&q.effectTriggered({effectId:o,parentEffectId:n,label:r,effect:e});var a=void 0;t.cancel=s.noop,u.cancel=function(){if(!a){a=!0;try{t.cancel()}catch(e){(0,s.log)("error","uncaught at "+K,e.message)}t.cancel=s.noop,q&&q.effectCancelled(o)}};var i=void 0;return s.is.promise(e)?_(e,t):s.is.iterator(e)?j(e,o,K,t):s.is.array(e)?S(e,o,t):s.is.notUndef(i=p.asEffect.take(e))?O(i,t):s.is.notUndef(i=p.asEffect.put(e))?w(i,t):s.is.notUndef(i=p.asEffect.race(e))?R(i,o,t):s.is.notUndef(i=p.asEffect.call(e))?A(i,o,t):s.is.notUndef(i=p.asEffect.cps(e))?C(i,t):s.is.notUndef(i=p.asEffect.fork(e))?P(i,o,t):s.is.notUndef(i=p.asEffect.join(e))?T(i,t):s.is.notUndef(i=p.asEffect.cancel(e))?N(i,t):s.is.notUndef(i=p.asEffect.select(e))?x(i,t):s.is.notUndef(i=p.asEffect.actionChannel(e))?M(i,t):s.is.notUndef(i=p.asEffect.cancelled(e))?U(i,t):t(e)}function _(e,n){var t=e[y];"function"==typeof t&&(n.cancel=t),e.then(n,function(e){return n(e,!0)})}function j(e,n,t,r){f(e,D,I,F,q,n,t,r)}function O(e,n){var t=e.channel,r=e.pattern,u=e.maybe;t=t||V;var o=function(e){return e instanceof Error?n(e,!0):n(e!==v.END||u?e:m)};try{t.take(o,i(r))}catch(a){return n(a,!0)}n.cancel=o.cancel}function w(e,n){var t=e.channel,r=e.action;(0,d.default)(function(){var e=void 0;try{e=(t?t.put:I)(r)}catch(u){return n(u,!0)}return s.is.promise(e)?void _(e,n):n(e)})}function A(e,n,t){var r=e.context,u=e.fn,o=e.args,a=void 0;try{a=u.apply(r,o)}catch(i){return t(i,!0)}return s.is.promise(a)?_(a,t):s.is.iterator(a)?j(a,n,u.name,t):t(a)}function C(e,n){var t=e.context,r=e.fn,u=e.args;try{r.apply(t,u.concat(function(e,t){return s.is.undef(e)?n(t):n(e,!0)}))}catch(o){return n(o,!0)}}function P(e,n,t){var r=e.context,u=e.fn,o=e.args,a=e.detached,i=void 0,c=void 0,l=void 0;try{i=u.apply(r,o)}catch(p){if(!a)return t(p);c=p}l=s.is.iterator(i)?i:c?(0,s.makeIterator)(function(){throw c}):(0,s.makeIterator)(function(){var e=void 0,n={done:!1,value:i},t=function(e){return{done:!0,value:e}};return function(r){return e?t(r):(e=!0,n)}}()),d.default.suspend();var v=f(l,D,I,F,q,n,u.name,a?null:s.noop);if(!a)if(l._isRunning)G.addTask(v);else if(l._error)return t(l._error,!0);t(v),d.default.flush()}function T(e,n){e.isRunning()?!function(){var t={task:W,cb:n};n.cancel=function(){return(0,s.remove)(e.joiners,t)},e.joiners.push(t)}():e.isAborted()?n(e.error(),!0):n(e.result())}function N(e,n){e.isRunning()&&e.cancel(),n()}function S(e,n,t){function r(){u===a.length&&(o=!0,t(a))}if(!e.length)return t([]);var u=0,o=void 0,a=Array(e.length),i=e.map(function(e,n){var i=function(e,i){o||(i||e===v.END||e===m||e===k?(t.cancel(),t(e,i)):(a[n]=e,u++,r()))};return i.cancel=s.noop,i});t.cancel=function(){o||(o=!0,i.forEach(function(e){return e.cancel()}))},e.forEach(function(e,t){return E(e,n,t,i[t])})}function R(e,n,t){var r=void 0,u=Object.keys(e),o={};u.forEach(function(e){var n=function(n,u){r||(u?(t.cancel(),t(n,!0)):n!==v.END&&n!==m&&n!==k&&(t.cancel(),r=!0,t(a({},e,n))))};n.cancel=s.noop,o[e]=n}),t.cancel=function(){r||(r=!0,u.forEach(function(e){return o[e].cancel()}))},u.forEach(function(t){return E(e[t],n,t,o[t])})}function x(e,n){var t=e.selector,r=e.args;try{var u=t.apply(void 0,[F()].concat(o(r)));n(u)}catch(a){n(a,!0)}}function M(e,n){var t=e.pattern,r=e.buffer,u=i(t);u.pattern=t,n((0,v.eventChannel)(D,r||h.buffers.fixed(),u))}function U(e,n){n(!!Y.isCancelled)}function L(e,n,r,o){var i,c,f;return r._deferredEnd=null,c={},a(c,s.TASK,!0),a(c,"id",e),a(c,"name",n),i="done",f={},f[i]=f[i]||{},f[i].get=function(){if(r._deferredEnd)return r._deferredEnd.promise;var e=(0,s.deferred)();return r._deferredEnd=e,r._isRunning||(r._error?e.reject(r._error):e.resolve(r._result)),e.promise},a(c,"cont",o),a(c,"joiners",[]),a(c,"cancel",t),a(c,"isRunning",function(){return r._isRunning}),a(c,"isCancelled",function(){return r._isCancelled}),a(c,"isAborted",function(){return r._isAborted}),a(c,"result",function(){return r._result}),a(c,"error",function(){return r._error}),u(c,f),c}var D=arguments.length<=1||void 0===arguments[1]?function(){return s.noop}:arguments[1],I=arguments.length<=2||void 0===arguments[2]?s.noop:arguments[2],F=arguments.length<=3||void 0===arguments[3]?s.noop:arguments[3],q=arguments[4],H=arguments.length<=5||void 0===arguments[5]?0:arguments[5],K=arguments.length<=6||void 0===arguments[6]?"anonymous":arguments[6],B=arguments[7];(0,s.check)(e,s.is.iterator,g);var V=(0,v.eventChannel)(D);r.cancel=s.noop;var W=L(H,K,e,B),Y={name:K,cancel:n,isRunning:!0},G=c(K,Y,l);return B&&(B.cancel=t),e._isRunning=!0,r(),W}Object.defineProperty(n,"__esModule",{value:!0}),n.TASK_CANCEL=n.CHANNEL_END=n.CANCEL=n.NOT_ITERATOR_ERROR=void 0,n.default=f;var s=t(1),l=t(7),d=r(l),p=t(3),v=t(2),h=t(4),g=n.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",y=n.CANCEL=(0,s.sym)("cancelPromise"),b=(0,s.autoInc)(),m=n.CHANNEL_END={toString:function(){return"@@redux-saga/CHANNEL_END"}},k=n.TASK_CANCEL={toString:function(){return"@@redux-saga/TASK_CANCEL"}},E={wildcard:function(){return s.kTrue},"default":function(e){return function(n){return n.type===e}},array:function(e){return function(n){return e.some(function(e){return e===n.type})}},predicate:function(e){return function(n){return e(n)}}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(3);Object.defineProperty(n,"take",{enumerable:!0,get:function(){return r.take}}),Object.defineProperty(n,"takem",{enumerable:!0,get:function(){return r.takem}}),Object.defineProperty(n,"put",{enumerable:!0,get:function(){return r.put}}),Object.defineProperty(n,"race",{enumerable:!0,get:function(){return r.race}}),Object.defineProperty(n,"call",{enumerable:!0,get:function(){return r.call}}),Object.defineProperty(n,"apply",{enumerable:!0,get:function(){return r.apply}}),Object.defineProperty(n,"cps",{enumerable:!0,get:function(){return r.cps}}),Object.defineProperty(n,"fork",{enumerable:!0,get:function(){return r.fork}}),Object.defineProperty(n,"spawn",{enumerable:!0,get:function(){return r.spawn}}),Object.defineProperty(n,"join",{enumerable:!0,get:function(){return r.join}}),Object.defineProperty(n,"cancel",{enumerable:!0,get:function(){return r.cancel}}),Object.defineProperty(n,"select",{enumerable:!0,get:function(){return r.select}}),Object.defineProperty(n,"actionChannel",{enumerable:!0,get:function(){return r.actionChannel}}),Object.defineProperty(n,"cancelled",{enumerable:!0,get:function(){return r.cancelled}})},function(e,n){"use strict";function t(e){u?r.push(e):(u=!0,r.push(e),t.flush())}Object.defineProperty(n,"__esModule",{value:!0}),n.default=t;var r=[],u=!1;t.suspend=function(){return u=!0},t.flush=function(){for(var e=void 0;e=r.shift();)e();u=!1}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(){function e(e){function r(e){for(var t=arguments.length,r=Array(t>1?t-1:0),c=1;t>c;c++)r[c-1]=arguments[c];return(0,i.default)(e.apply(void 0,r),a.subscribe,o,u,n.sagaMonitor,0,e.name)}var u=e.getState,o=e.dispatch;t=r;var a=(0,c.emitter)();return function(e){return function(n){var t=e(n);return a.emit(n),t}}}var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=void 0;if(o.is.func(n))throw new Error("You passed a function to the Saga middleware. You are likely trying to start a Saga by directly passing it to the middleware. This is no longer possible starting from 0.10.0. To run a Saga, you must do it dynamically AFTER mounting the middleware into the store.\n Example:\n import createSagaMiddleware from 'redux-saga'\n ... other imports\n\n const sagaMiddleware = createSagaMiddleware()\n const store = createStore(reducer, applyMiddleware(sagaMiddleware))\n sagaMiddleware.run(saga, ...args)\n ");return e.run=function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),u=1;n>u;u++)r[u-1]=arguments[u];return(0,o.check)(t,o.is.notUndef,"Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware"),(0,o.check)(e,o.is.func,"sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!"),t.apply(void 0,[e].concat(r))},e}Object.defineProperty(n,"__esModule",{value:!0}),n.default=u;var o=t(1),a=t(5),i=r(a),c=t(2)},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function u(e,n,t){var r=n.subscribe,u=n.dispatch,a=n.getState;return(0,o.check)(e,o.is.iterator,"runSaga must be called on an iterator"),(0,i.default)(e,r,u,a,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.runSaga=u;var o=t(1),a=t(5),i=r(a)},function(e,n,t){"use strict";function r(e,n){function t(n,t){if(o===l)return s;if(t)throw o=l,t;u&&u(n);var r=e[o](),i=a(r,3),c=i[0],f=i[1],d=i[2];return o=c,u=d,o===l?s:f}var r=arguments.length<=2||void 0===arguments[2]?"iterator":arguments[2],u=void 0,o=n;return(0,c.makeIterator)(t,function(e){return t(null,e)},r)}function u(e,n){for(var t=arguments.length,u=Array(t>2?t-2:0),o=2;t>o;o++)u[o-2]=arguments[o];var a={done:!1,value:(0,f.take)(e)},c=function(e){return{done:!1,value:f.fork.apply(void 0,[n].concat(u,[e]))}},s=void 0,d=function(e){return s=e};return r({q1:function(){return["q2",a,d]},q2:function(){return s===i.END?[l]:["q1",c(s)]}},"q1","takeEvery("+String(e)+", "+n.name+")")}function o(e,n){for(var t=arguments.length,u=Array(t>2?t-2:0),o=2;t>o;o++)u[o-2]=arguments[o];var a={done:!1,value:(0,f.take)(e)},c=function(e){return{done:!1,value:f.fork.apply(void 0,[n].concat(u,[e]))}},s=function(e){return{done:!1,value:(0,f.cancel)(e)}},d=void 0,p=void 0,v=function(e){return d=e},h=function(e){return p=e};return r({q1:function(){return["q2",a,h]},q2:function(){return p===i.END?[l]:d?["q3",s(d)]:["q1",c(p),v]},q3:function(){return["q1",c(p),v]}},"q1","takeLatest("+String(e)+", "+n.name+")")}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,n){var t=[],r=!0,u=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(t.push(a.value),!n||t.length!==n);r=!0);}catch(c){u=!0,o=c}finally{try{!r&&i.return&&i.return()}finally{if(u)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.takeEvery=u,n.takeLatest=o;var i=t(2),c=t(1),f=t(3),s={done:!0,value:void 0},l={}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(1);Object.defineProperty(n,"TASK",{enumerable:!0,get:function(){return r.TASK}}),Object.defineProperty(n,"noop",{enumerable:!0,get:function(){return r.noop}}),Object.defineProperty(n,"is",{enumerable:!0,get:function(){return r.is}}),Object.defineProperty(n,"deferred",{enumerable:!0,get:function(){return r.deferred}}),Object.defineProperty(n,"arrayOfDeffered",{enumerable:!0,get:function(){return r.arrayOfDeffered}}),Object.defineProperty(n,"createMockTask",{enumerable:!0,get:function(){return r.createMockTask}});var u=t(3);Object.defineProperty(n,"asEffect",{enumerable:!0,get:function(){return u.asEffect}})},function(e,n){function t(){f=!1,a.length?c=a.concat(c):s=-1,c.length&&r()}function r(){if(!f){var e=setTimeout(t);f=!0;for(var n=c.length;n;){for(a=c,c=[];++s<n;)a&&a[s].run();s=-1,n=c.length}a=null,f=!1,clearTimeout(e)}}function u(e,n){this.fun=e,this.array=n}function o(){}var a,i=e.exports={},c=[],f=!1,s=-1;i.nextTick=function(e){var n=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];c.push(new u(e,n)),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(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}])}); |
@@ -494,9 +494,9 @@ 'use strict'; | ||
(0, _asap2.default)(function () { | ||
var task = proc(_iterator, subscribe, dispatch, getState, monitor, effectId, fn.name, detached ? null : _utils.noop); | ||
if (!detached) { | ||
if (_iterator._isRunning) taskQueue.addTask(task);else if (_iterator._error) return cb(_iterator._error, true); | ||
} | ||
cb(task); | ||
}); | ||
_asap2.default.suspend(); | ||
var task = proc(_iterator, subscribe, dispatch, getState, monitor, effectId, fn.name, detached ? null : _utils.noop); | ||
if (!detached) { | ||
if (_iterator._isRunning) taskQueue.addTask(task);else if (_iterator._error) return cb(_iterator._error, true); | ||
} | ||
cb(task); | ||
_asap2.default.flush(); | ||
// Fork effects are non cancellables | ||
@@ -503,0 +503,0 @@ } |
{ | ||
"name": "redux-saga", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "Saga middleware for Redux to handle Side Effects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
125
README.md
# redux-saga | ||
[![Join the chat at https://gitter.im/yelouafi/redux-saga](https://badges.gitter.im/yelouafi/redux-saga.svg)](https://gitter.im/yelouafi/redux-saga?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![npm version](https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga) | ||
[![Join the chat at https://gitter.im/yelouafi/redux-saga](https://badges.gitter.im/yelouafi/redux-saga.svg)](https://gitter.im/yelouafi/redux-saga?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![npm version](https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga) | ||
An alternative Side Effects middleware (aka Asynchronous Actions) for Redux applications. | ||
Instead of dispatching Thunks which get handled by the `redux-thunk` middleware, you | ||
create *Sagas* to gather all your Side Effects logic in a central place. | ||
An alternative Side Effects middleware (aka Asynchronous Actions) for Redux applications. Instead of dispatching Thunks which get handled by the `redux-thunk` middleware, you create *Sagas* to gather all your Side Effects logic in a central place. | ||
@@ -13,31 +10,15 @@ This means application logic lives in 2 places: | ||
- Reducers are responsible for handling state transitions between actions. | ||
- Sagas are responsible for orchestrating complex/asynchronous operations. | ||
Sagas are created using Generator functions. If you're not familiar with them you may find | ||
[some useful links here.](http://yelouafi.github.io/redux-saga/docs/ExternalResources.html) | ||
Sagas are created using Generator functions. If you're not familiar with them you may find [some useful links here.](http://yelouafi.github.io/redux-saga/docs/ExternalResources.html) | ||
Unlike Thunks which get invoked on every action by Action Creators, Sagas are fired only | ||
once at the start of the application (but startup Sagas may fire other Sagas dynamically). | ||
They can be seen as Processes running in the background. Sagas watch the actions dispatched | ||
to the Store, then decide what to do based on dispatched actions: Either making an asynchronous | ||
call (like an AJAX request), dispatching other actions to the Store, or even starting other | ||
Sagas dynamically. | ||
Unlike Thunks which get invoked on every action by Action Creators, Sagas are fired only once at the start of the application (but startup Sagas may fire other Sagas dynamically). They can be seen as Processes running in the background. Sagas watch the actions dispatched to the Store, then decide what to do based on dispatched actions: Either making an asynchronous call (like an AJAX request), dispatching other actions to the Store, or even starting other Sagas dynamically. | ||
In `redux-saga` all the above tasks are achieved by yielding **Effects**. Effects are simply | ||
JavaScript Objects containing instructions to be executed by the Saga middleware (As an analogy, | ||
you can see Redux actions as Objects containing instructions to be executed by the Store). | ||
`redux-saga` provides Effect creators for various tasks like calling an asynchronous function, | ||
dispatching an action to the Store, starting a background task or waiting for a future action | ||
that satisfies a certain condition. | ||
In `redux-saga` all the above tasks are achieved by yielding **Effects**. Effects are simply JavaScript Objects containing instructions to be executed by the Saga middleware (As an analogy, you can see Redux actions as Objects containing instructions to be executed by the Store). `redux-saga` provides Effect creators for various tasks like calling an asynchronous function, dispatching an action to the Store, starting a background task or waiting for a future action that satisfies a certain condition. | ||
Using Generators, `redux-saga` allows you to write your asynchronous code in a simple | ||
synchronous style. Just like you can do with `async/await` functions. But Generators | ||
allow some things that aren't possible with `async` functions. | ||
Using Generators, `redux-saga` allows you to write your asynchronous code in a simple synchronous style. Just like you can do with `async/await` functions. But Generators allow some things that aren't possible with `async` functions. | ||
The fact that Sagas yield plain Objects makes it easy to test all the logic inside your Generator | ||
by simply iterating over the yielded Objects and doing simple equality tests. | ||
The fact that Sagas yield plain Objects makes it easy to test all the logic inside your Generator by simply iterating over the yielded Objects and doing simple equality tests. | ||
Furthermore, tasks started in `redux-saga` can be cancelled at any moment either manually | ||
or automatically by putting them in a race with other Effects. | ||
Furthermore, tasks started in `redux-saga` can be cancelled at any moment either manually or automatically by putting them in a race with other Effects. | ||
@@ -48,13 +29,11 @@ # Getting started | ||
```sh | ||
$ npm install --save redux-saga | ||
``` | ||
npm install --save redux-saga | ||
``` | ||
Alternatively, you may use the provided UMD builds directly in the `<script>` tag of | ||
an HTML page. See [this section.](#using-umd-build-in-the-browser) | ||
Alternatively, you may use the provided UMD builds directly in the `<script>` tag of an HTML page. See [this section](#using-umd-build-in-the-browser). | ||
## Usage Example | ||
Suppose we have an UI to fetch some user data from a remote server when a button is clicked | ||
(For brevity, we'll just show the action triggering code). | ||
Suppose we have an UI to fetch some user data from a remote server when a button is clicked. (For brevity, we'll just show the action triggering code.) | ||
@@ -72,7 +51,6 @@ ```javascript | ||
The Component dispatches a plain Object action to the Store. We'll create a Saga that | ||
watches for all `USER_FETCH_REQUESTED` actions and triggers an API call to fetch the | ||
user data. | ||
The Component dispatches a plain Object action to the Store. We'll create a Saga that watches for all `USER_FETCH_REQUESTED` actions and triggers an API call to fetch the user data. | ||
#### `sagas.js` | ||
```javascript | ||
@@ -83,3 +61,3 @@ import { takeEvery, takeLatest } from 'redux-saga' | ||
// worker Saga : will be fired on USER_FETCH_REQUESTED actions | ||
// worker Saga: will be fired on USER_FETCH_REQUESTED actions | ||
function* fetchUser(action) { | ||
@@ -95,4 +73,4 @@ try { | ||
/* | ||
starts fetchUser on each dispatched `USER_FETCH_REQUESTED` action | ||
Allow concurrent fetches of user | ||
Starts fetchUser on each dispatched `USER_FETCH_REQUESTED` action. | ||
Allows concurrent fetches of user. | ||
*/ | ||
@@ -104,7 +82,7 @@ function* mySaga() { | ||
/* | ||
Alternatively you may use takeLatest | ||
Alternatively you may use takeLatest. | ||
Do not allow concurrent fetches of user, If "USER_FETCH_REQUESTED" gets | ||
Does not allow concurrent fetches of user. If "USER_FETCH_REQUESTED" gets | ||
dispatched while a fetch is already pending, that pending fetch is cancelled | ||
and only the latest one will be run | ||
and only the latest one will be run. | ||
*/ | ||
@@ -119,2 +97,3 @@ function* mySaga() { | ||
#### `main.js` | ||
```javascript | ||
@@ -154,4 +133,3 @@ import { createStore, applyMiddleware } from 'redux' | ||
There's also an **umd** build of `redux-saga` available in the `dist/` folder. When using the umd build | ||
`redux-saga` is available as `ReduxSaga` in the window object. | ||
There is also a **umd** build of `redux-saga` available in the `dist/` folder. When using the umd build `redux-saga` is available as `ReduxSaga` in the window object. | ||
@@ -165,6 +143,3 @@ The umd version is useful if you don't use Webpack or Browserify. You can access it directly from [npmcdn](npmcdn.com). | ||
**Important!** If the browser you are targeting doesn't support _es2015 generators_ you must provide a valid polyfill, | ||
for example the one provided by *babel*: | ||
[browser-polyfill.min.js](https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser-polyfill.min.js). | ||
The polyfill must be imported before **redux-saga**. | ||
**Important!** If the browser you are targeting doesn't support *ES2015 generators*, you must provide a valid polyfill, such as [the one provided by `babel`](https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser-polyfill.min.js). The polyfill must be imported before **redux-saga**: | ||
@@ -179,8 +154,8 @@ ```javascript | ||
```sh | ||
$ git clone https://github.com/yelouafi/redux-saga.git | ||
$ cd redux-saga | ||
$ npm install | ||
$ npm test | ||
``` | ||
git clone https://github.com/yelouafi/redux-saga.git | ||
cd redux-saga | ||
npm install | ||
npm test | ||
``` | ||
@@ -191,23 +166,21 @@ Below are the examples ported (so far) from the Redux repos. | ||
There are 3 counter examples. | ||
There are three counter examples. | ||
#### counter-vanilla | ||
Demo using vanilla JavaScript and UMD builds. All source is inlined in `index.html` | ||
Demo using vanilla JavaScript and UMD builds. All source is inlined in `index.html`. | ||
To launch the example, just open `index.html` in your browser. | ||
>Important | ||
Your browser must support Generators. Latest versions of Chrome/Firefox/Edge are suitable. | ||
> Important: your browser must support Generators. Latest versions of Chrome/Firefox/Edge are suitable. | ||
#### counter | ||
Demo using webpack and high level API `takeEvery` | ||
Demo using `webpack` and high-level API `takeEvery`. | ||
``` | ||
npm run counter | ||
```sh | ||
$ npm run counter | ||
// test sample for the generator | ||
npm run test-counter | ||
# test sample for the generator | ||
$ npm run test-counter | ||
``` | ||
@@ -217,15 +190,15 @@ | ||
Demo using low level API. Demonstrate task cancellation. | ||
Demo using low-level API to demonstrate task cancellation. | ||
```sh | ||
$ npm run cancellable-counter | ||
``` | ||
npm run cancellable-counter | ||
``` | ||
### Shopping Cart example | ||
``` | ||
npm run shop | ||
```sh | ||
$ npm run shop | ||
// test sample for the generator | ||
npm run test-shop | ||
# test sample for the generator | ||
$ npm run test-shop | ||
``` | ||
@@ -235,6 +208,6 @@ | ||
``` | ||
npm run async | ||
```sh | ||
$ npm run async | ||
//sorry, no tests yet | ||
# sorry, no tests yet | ||
``` | ||
@@ -244,6 +217,6 @@ | ||
``` | ||
npm run real-world | ||
```sh | ||
$ npm run real-world | ||
//sorry, no tests yet | ||
# sorry, no tests yet | ||
``` |
@@ -465,12 +465,12 @@ import { sym, noop, kTrue, is, log, check, deferred, isDev, autoInc, remove, TASK, makeIterator } from './utils' | ||
asap(() => { | ||
let task = proc(_iterator, subscribe, dispatch, getState, monitor, effectId, fn.name, (detached ? null : noop)) | ||
if(!detached) { | ||
if(_iterator._isRunning) | ||
taskQueue.addTask(task) | ||
else if(_iterator._error) | ||
return cb(_iterator._error, true) | ||
} | ||
cb(task) | ||
}) | ||
asap.suspend() | ||
let task = proc(_iterator, subscribe, dispatch, getState, monitor, effectId, fn.name, (detached ? null : noop)) | ||
if(!detached) { | ||
if(_iterator._isRunning) | ||
taskQueue.addTask(task) | ||
else if(_iterator._error) | ||
return cb(_iterator._error, true) | ||
} | ||
cb(task) | ||
asap.flush() | ||
// Fork effects are non cancellables | ||
@@ -477,0 +477,0 @@ } |
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
285445
40
4287
209