redux-saga
Advanced tools
Comparing version 0.12.1 to 0.13.0
@@ -0,0 +0,0 @@ { |
@@ -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 o=t[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.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 o(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.effects=e.CANCEL=e.delay=e.throttle=e.takeLatest=e.takeEvery=e.buffers=e.channel=e.eventChannel=e.END=e.runSaga=void 0;var u=t(9);Object.defineProperty(e,"runSaga",{enumerable:!0,get:function(){return u.runSaga}});var i=t(3);Object.defineProperty(e,"END",{enumerable:!0,get:function(){return i.END}}),Object.defineProperty(e,"eventChannel",{enumerable:!0,get:function(){return i.eventChannel}}),Object.defineProperty(e,"channel",{enumerable:!0,get:function(){return i.channel}});var a=t(2);Object.defineProperty(e,"buffers",{enumerable:!0,get:function(){return a.buffers}});var c=t(10);Object.defineProperty(e,"takeEvery",{enumerable:!0,get:function(){return c.takeEvery}}),Object.defineProperty(e,"takeLatest",{enumerable:!0,get:function(){return c.takeLatest}}),Object.defineProperty(e,"throttle",{enumerable:!0,get:function(){return c.throttle}});var f=t(1);Object.defineProperty(e,"delay",{enumerable:!0,get:function(){return f.delay}}),Object.defineProperty(e,"CANCEL",{enumerable:!0,get:function(){return f.CANCEL}});var l=t(8),s=o(l),d=t(6),v=r(d),h=t(11),p=r(h);e.default=s.default,e.effects=v,e.utils=p},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,t){if(!e(n))throw s("error","uncaught at check",t),new Error(t)}function o(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=d({},n),t=new Promise(function(n,t){e.resolve=n,e.reject=t});return e.promise=t,e}function i(n){for(var e=[],t=0;t<n;t++)e.push(u());return e}function a(n){var e=arguments.length<=1||void 0===arguments[1]||arguments[1],t=void 0,r=new Promise(function(r){t=setTimeout(function(){return r(e)},n)});return r[y]=function(){return clearTimeout(t)},r}function c(){var n,e=!0,r=void 0,o=void 0;return n={},t(n,p,!0),t(n,"isRunning",function(){return e}),t(n,"result",function(){return r}),t(n,"error",function(){return o}),t(n,"setRunning",function(n){return e=n}),t(n,"setResult",function(n){return r=n}),t(n,"setError",function(n){return o=n}),n}function f(){var n=arguments.length<=0||void 0===arguments[0]?0:arguments[0];return function(){return++n}}function l(n){var e=arguments.length<=1||void 0===arguments[1]?E:arguments[1],t=arguments.length<=2||void 0===arguments[2]?"":arguments[2],r=arguments[3],o={name:t,next:n,"throw":e,"return":k};return r&&(o[g]=!0),"undefined"!=typeof Symbol&&(o[Symbol.iterator]=function(){return o}),o}function s(n,e,t){"undefined"==typeof window?console.log("redux-saga "+n+": "+e+"\n"+(t&&t.stack||t)):console[n](e,t)}Object.defineProperty(e,"__esModule",{value:!0});var d=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},v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol?"symbol":typeof n};e.check=r,e.remove=o,e.deferred=u,e.arrayOfDeffered=i,e.delay=a,e.createMockTask=c,e.autoInc=f,e.makeIterator=l,e.log=s;var h=e.sym=function(n){return"@@redux-saga/"+n},p=e.TASK=h("TASK"),g=e.HELPER=h("HELPER"),y=(e.MATCH=h("MATCH"),e.CANCEL=h("cancelPromise")),b=e.konst=function(n){return function(){return n}},m=(e.kTrue=b(!0),e.kFalse=b(!1),e.noop=function(){},e.ident=function(n){return n},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},number:function(n){return"number"==typeof n},array:Array.isArray,promise:function(n){return n&&m.func(n.then)},iterator:function(n){return n&&m.func(n.next)&&m.func(n.throw)},task:function(n){return n&&n[p]},observable:function(n){return n&&m.func(n.subscribe)},buffer:function(n){return n&&m.func(n.isEmpty)&&m.func(n.take)&&m.func(n.put)},pattern:function(n){return n&&("string"==typeof n||"symbol"===("undefined"==typeof n?"undefined":v(n))||m.func(n)||m.array(n))},channel:function(n){return n&&m.func(n.take)&&m.func(n.close)},helper:function(n){return n&&n[g]}}),E=function(n){throw n},k=function(n){return{value:n,done:!0}};e.internalErr=function(n){return new Error("\n redux-saga: Error checking hooks detected an inconsistent 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: "+n+"\n")}},function(n,e,t){"use strict";function r(){var n=arguments.length<=0||void 0===arguments[0]?10:arguments[0],e=arguments[1],t=new Array(n),r=0,o=0,a=0,l=function(e){t[o]=e,o=(o+1)%n,r++},s=function(){if(0!=r){var e=t[a];return t[a]=null,r--,a=(a+1)%n,e}},d=function(){for(var n=[];r;)n.push(s());return n};return{isEmpty:function(){return 0==r},put:function(s){if(r<n)l(s);else{var v=void 0;switch(e){case i:throw new Error(u);case c:t[o]=s,o=(o+1)%n,a=o;break;case f:v=2*n,t=d(),r=t.length,o=t.length,a=0,t.length=v,n=v,l(s)}}},take:s,flush:d}}Object.defineProperty(e,"__esModule",{value:!0}),e.buffers=e.BUFFER_OVERFLOW=void 0;var o=t(1),u=e.BUFFER_OVERFLOW="Channel's Buffer overflow!",i=1,a=2,c=3,f=4,l={isEmpty:o.kTrue,put:o.noop,take:o.noop};e.buffers={none:function(){return l},fixed:function(n){return r(n,i)},dropping:function(n){return r(n,a)},sliding:function(n){return r(n,c)},expanding:function(n){return r(n,f)}}},function(n,e,t){"use strict";function r(){function n(n){return t.push(n),function(){return(0,c.remove)(t,n)}}function e(n){for(var e=t.slice(),r=0,o=e.length;r<o;r++)e[r](n)}var t=[];return{subscribe:n,emit:e}}function o(){function n(){if(i&&a.length)throw(0,c.internalErr)("Cannot have a closed channel with pending takers");if(a.length&&!u.isEmpty())throw(0,c.internalErr)("Cannot have pending takers with non empty buffer")}function e(e){if(n(),(0,c.check)(e,c.is.notUndef,h),!i){if(!a.length)return u.put(e);for(var t=0;t<a.length;t++){var r=a[t];if(!r[c.MATCH]||r[c.MATCH](e))return a.splice(t,1),r(e)}}}function t(e){n(),(0,c.check)(e,c.is.func,"channel.take's callback must be a function"),i&&u.isEmpty()?e(s):u.isEmpty()?(a.push(e),e.cancel=function(){return(0,c.remove)(a,e)}):e(u.take())}function r(e){return n(),(0,c.check)(e,c.is.func,"channel.flush' callback must be a function"),i&&u.isEmpty()?void e(s):void e(u.flush())}function o(){if(n(),!i&&(i=!0,a.length)){var e=a;a=[];for(var t=0,r=e.length;t<r;t++)e[t](s)}}var u=arguments.length<=0||void 0===arguments[0]?f.buffers.fixed():arguments[0],i=!1,a=[];return(0,c.check)(u,c.is.buffer,v),{take:t,put:e,flush:r,close:o,get __takers__(){return a},get __closed__(){return i}}}function u(n){var e=arguments.length<=1||void 0===arguments[1]?f.buffers.none():arguments[1],t=arguments[2];arguments.length>2&&(0,c.check)(t,c.is.func,"Invalid match function passed to eventChannel");var r=o(e),u=n(function(n){d(n)?r.close():t&&!t(n)||r.put(n)});if(!c.is.func(u))throw new Error("in eventChannel: subscribe should return a function to unsubscribe");return{take:r.take,flush:r.flush,close:function(){r.__closed__||(r.close(),u())}}}function i(n){var e=u(n);return a({},e,{take:function(n,t){arguments.length>1&&((0,c.check)(t,c.is.func,"channel.take's matcher argument must be a function"),n[c.MATCH]=t),e.take(n)}})}Object.defineProperty(e,"__esModule",{value:!0}),e.UNDEFINED_INPUT_ERROR=e.INVALID_BUFFER=e.isEnd=e.END=void 0;var a=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};e.emitter=r,e.channel=o,e.eventChannel=u,e.stdChannel=i;var c=t(1),f=t(2),l="@@redux-saga/CHANNEL_END",s=e.END={type:l},d=e.isEnd=function(n){return n&&n.type===l},v=e.INVALID_BUFFER="invalid buffer passed to channel factory function",h=e.UNDEFINED_INPUT_ERROR="Saga was provided with an undefined action"},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 o(){var n=arguments.length<=0||void 0===arguments[0]?"*":arguments[0];if(arguments.length&&(0,k.check)(arguments[0],k.is.notUndef,"take(patternOrChannel): patternOrChannel is undefined"),k.is.pattern(n))return M(O,{pattern:n});if(k.is.channel(n))return M(O,{channel:n});throw new Error("take(patternOrChannel): argument "+String(n)+" is not valid channel or a valid pattern")}function u(){var n=o.apply(void 0,arguments);return n[O].maybe=!0,n}function i(n,e){return arguments.length>1?((0,k.check)(n,k.is.notUndef,"put(channel, action): argument channel is undefined"),(0,k.check)(n,k.is.channel,"put(channel, action): argument "+n+" is not a valid channel"),(0,k.check)(e,k.is.notUndef,"put(channel, action): argument action is undefined")):((0,k.check)(n,k.is.notUndef,"put(action): argument action is undefined"),e=n,n=null),M(j,{channel:n,action:e})}function a(n){return M(C,n)}function c(n,e,t){(0,k.check)(e,k.is.notUndef,n+": argument fn is undefined");var r=null;if(k.is.array(e)){var o=e,u=E(o,2);r=u[0],e=u[1]}else if(e.fn){var i=e;r=i.context,e=i.fn}return(0,k.check)(e,k.is.func,n+": argument "+e+" is not a function"),{context:r,fn:e,args:t}}function f(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return M(A,c("call",n,t))}function l(n,e){var t=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return M(A,c("apply",{context:n,fn:e},t))}function s(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return M(w,c("cps",n,t))}function d(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return M(P,c("fork",n,t))}function v(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];var o=d.apply(void 0,[n].concat(t));return o[P].detached=!0,o}function h(n){if((0,k.check)(n,k.is.notUndef,"join(task): argument task is undefined"),!L(n))throw new Error("join(task): argument "+n+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return M(T,n)}function p(n){if((0,k.check)(n,k.is.notUndef,"cancel(task): argument task is undefined"),!L(n))throw new Error("cancel(task): argument "+n+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return M(S,n)}function g(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return 0===arguments.length?n=k.ident:((0,k.check)(n,k.is.notUndef,"select(selector,[...]): argument selector is undefined"),(0,k.check)(n,k.is.func,"select(selector,[...]): argument "+n+" is not a function")),M(N,{selector:n,args:t})}function y(n,e){return(0,k.check)(n,k.is.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&((0,k.check)(e,k.is.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),(0,k.check)(e,k.is.notUndef,"actionChannel(pattern, buffer): argument "+e+" is not a valid buffer")),M(R,{pattern:n,buffer:e})}function b(){return M(x,{})}function m(n){return(0,k.check)(n,k.is.channel,"flush(channel): argument "+n+" is not valid channel"),M(U,n)}Object.defineProperty(e,"__esModule",{value:!0}),e.asEffect=void 0;var E=function(){function n(n,e){var t=[],r=!0,o=!1,u=void 0;try{for(var i,a=n[Symbol.iterator]();!(r=(i=a.next()).done)&&(t.push(i.value),!e||t.length!==e);r=!0);}catch(c){o=!0,u=c}finally{try{!r&&a.return&&a.return()}finally{if(o)throw u}}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")}}();e.take=o,e.takem=u,e.put=i,e.race=a,e.call=f,e.apply=l,e.cps=s,e.fork=d,e.spawn=v,e.join=h,e.cancel=p,e.select=g,e.actionChannel=y,e.cancelled=b,e.flush=m;var k=t(1),_=(0,k.sym)("IO"),O="TAKE",j="PUT",C="RACE",A="CALL",w="CPS",P="FORK",T="JOIN",S="CANCEL",N="SELECT",R="ACTION_CHANNEL",x="CANCELLED",U="FLUSH",M=function(n,e){var t;return t={},r(t,_,!0),r(t,n,e),t};i.sync=function(){var n=i.apply(void 0,arguments);return n[j].sync=!0,n};var L=function(n){return n[k.TASK]};e.asEffect={take:function(n){return n&&n[_]&&n[O]},put:function(n){return n&&n[_]&&n[j]},race:function(n){return n&&n[_]&&n[C]},call:function(n){return n&&n[_]&&n[A]},cps:function(n){return n&&n[_]&&n[w]},fork:function(n){return n&&n[_]&&n[P]},join:function(n){return n&&n[_]&&n[T]},cancel:function(n){return n&&n[_]&&n[S]},select:function(n){return n&&n[_]&&n[N]},actionChannel:function(n){return n&&n[_]&&n[R]},cancelled:function(n){return n&&n[_]&&n[x]},flush:function(n){return n&&n[_]&&n[U]}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function o(n,e){for(var t in e){var r=e[t];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,t,r)}return 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 i(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){return("*"===n?O.wildcard:d.is.array(n)?O.array:d.is.func(n)?O.predicate:O.default)(n)}function c(n,e,t){function r(n){u(),t(n,!0)}function o(n){i.push(n),n.cont=function(o,u){c||((0,d.remove)(i,n),n.cont=d.noop,u?r(o):(n===e&&(a=o),i.length||(c=!0,t(a))))}}function u(){c||(c=!0,i.forEach(function(n){n.cont=d.noop,n.cancel()}),i=[])}var i=[],a=void 0,c=!1;return o(e),{addTask:o,cancelAll:u,abort:r,getTasks:function(){return i},taskNames:function(){return i.map(function(n){return n.name})}}}function f(n){var e=n.context,t=n.fn,r=n.args;if(d.is.iterator(t))return t;var o=void 0,u=void 0;try{o=t.apply(e,r)}catch(i){u=i}return d.is.iterator(o)?o:u?(0,d.makeIterator)(function(){throw u}):(0,d.makeIterator)(function(){var n=void 0,e={done:!1,value:o},t=function(n){return{done:!0,value:n}};return function(r){return n?t(r):(n=!0,e)}}())}function l(n){return{fn:n}}function s(n){function e(){$.isRunning&&!$.isCancelled&&($.isCancelled=!0,r(_))}function t(){n._isRunning&&!n._isCancelled&&(n._isCancelled=!0,nn.cancelAll(),v(_))}function r(e,t){if(!$.isRunning)throw new Error("Trying to resume an already finished generator");try{var o=void 0;t?o=n.throw(e):e===_?($.isCancelled=!0,r.cancel(),o=d.is.func(n.return)?n.return(_):{done:!0,value:_}):o=e===k?d.is.func(n.return)?n.return():{done:!0}:n.next(e),o.done?($.isMainRunning=!1,$.cont&&$.cont(o.value)):O(o.value,V,"",r)}catch(u){$.isCancelled&&X("error","uncaught at "+G,u.message),$.isMainRunning=!1,$.cont(u,!0)}}function v(e,t){n._isRunning=!1,Y.close(),t?(e instanceof Error&&(e.sagaStack="at "+G+" \n "+(e.sagaStack||e.stack)),Z.cont||(X("error","uncaught",e.sagaStack||e.stack),e instanceof Error&&Q&&Q(e)),n._error=e,n._isAborted=!0,n._deferredEnd&&n._deferredEnd.reject(e)):(e===_&&b&&X("info",G+" has been cancelled",""),n._result=e,n._deferredEnd&&n._deferredEnd.resolve(e)),Z.cont&&Z.cont(e,t),Z.joiners.forEach(function(n){return n.cb(e,t)}),Z.joiners=null}function O(n,e){function t(n,e){i||(i=!0,o.cancel=d.noop,J&&(e?J.effectRejected(u,n):J.effectResolved(u,n)),o(n,e))}var r=arguments.length<=2||void 0===arguments[2]?"":arguments[2],o=arguments[3],u=E();J&&J.effectTriggered({effectId:u,parentEffectId:e,label:r,effect:n});var i=void 0;t.cancel=d.noop,o.cancel=function(){if(!i){i=!0;try{t.cancel()}catch(n){X("error","uncaught at "+G,n.message)}t.cancel=d.noop,J&&J.effectCancelled(u)}};var a=void 0;return d.is.promise(n)?j(n,t):d.is.helper(n)?S(l(n),u,t):d.is.iterator(n)?C(n,u,G,t):d.is.array(n)?x(n,u,t):d.is.notUndef(a=p.asEffect.take(n))?A(a,t):d.is.notUndef(a=p.asEffect.put(n))?w(a,t):d.is.notUndef(a=p.asEffect.race(n))?U(a,u,t):d.is.notUndef(a=p.asEffect.call(n))?P(a,u,t):d.is.notUndef(a=p.asEffect.cps(n))?T(a,t):d.is.notUndef(a=p.asEffect.fork(n))?S(a,u,t):d.is.notUndef(a=p.asEffect.join(n))?N(a,t):d.is.notUndef(a=p.asEffect.cancel(n))?R(a,t):d.is.notUndef(a=p.asEffect.select(n))?M(a,t):d.is.notUndef(a=p.asEffect.actionChannel(n))?L(a,t):d.is.notUndef(a=p.asEffect.flush(n))?q(a,t):d.is.notUndef(a=p.asEffect.cancelled(n))?I(a,t):t(n)}function j(n,e){var t=n[d.CANCEL];"function"==typeof t&&(e.cancel=t),n.then(e,function(n){return e(n,!0)})}function C(n,e,t,r){s(n,F,H,K,B,e,t,r)}function A(n,e){var t=n.channel,r=n.pattern,o=n.maybe;t=t||Y;var u=function(n){return n instanceof Error?e(n,!0):e((0,g.isEnd)(n)&&!o?k:n)};try{t.take(u,a(r))}catch(i){return e(i,!0)}e.cancel=u.cancel}function w(n,e){var t=n.channel,r=n.action,o=n.sync;(0,h.default)(function(){var n=void 0;try{n=(t?t.put:H)(r)}catch(u){if(t||o)return e(u,!0);X("error","uncaught at "+G,u.stack||u.message||u)}return o&&d.is.promise(n)?void j(n,e):e(n)})}function P(n,e,t){var r=n.context,o=n.fn,u=n.args,i=void 0;try{i=o.apply(r,u)}catch(a){return t(a,!0)}return d.is.promise(i)?j(i,t):d.is.iterator(i)?C(i,e,o.name,t):t(i)}function T(n,e){var t=n.context,r=n.fn,o=n.args;try{!function(){var n=function(n,t){return d.is.undef(n)?e(t):e(n,!0)};r.apply(t,o.concat(n)),n.cancel&&(e.cancel=function(){return n.cancel()})}()}catch(u){return e(u,!0)}}function S(n,e,t){var r=n.context,o=n.fn,u=n.args,i=n.detached,a=f({context:r,fn:o,args:u});h.default.suspend();var c=s(a,F,H,K,B,e,o.name,i?null:d.noop);i?t(c):a._isRunning?(nn.addTask(c),t(c)):a._error?nn.abort(a._error):t(c),h.default.flush()}function N(n,e){n.isRunning()?!function(){var t={task:Z,cb:e};e.cancel=function(){return(0,d.remove)(n.joiners,t)},n.joiners.push(t)}():n.isAborted()?e(n.error(),!0):e(n.result())}function R(n,e){n.isRunning()&&n.cancel(),e()}function x(n,e,t){function r(){o===i.length&&(u=!0,t(i))}if(!n.length)return t([]);var o=0,u=void 0,i=Array(n.length),a=n.map(function(n,e){var a=function(n,a){u||(a||(0,g.isEnd)(n)||n===k||n===_?(t.cancel(),t(n,a)):(i[e]=n,o++,r()))};return a.cancel=d.noop,a});t.cancel=function(){u||(u=!0,a.forEach(function(n){return n.cancel()}))},n.forEach(function(n,t){return O(n,e,t,a[t])})}function U(n,e,t){var r=void 0,o=Object.keys(n),u={};o.forEach(function(n){var e=function(e,o){r||(o?(t.cancel(),t(e,!0)):(0,g.isEnd)(e)||e===k||e===_||(t.cancel(),r=!0,t(i({},n,e))))};e.cancel=d.noop,u[n]=e}),t.cancel=function(){r||(r=!0,o.forEach(function(n){return u[n].cancel()}))},o.forEach(function(t){r||O(n[t],e,t,u[t])})}function M(n,e){var t=n.selector,r=n.args;try{var o=t.apply(void 0,[K()].concat(u(r)));e(o)}catch(i){e(i,!0)}}function L(n,e){var t=n.pattern,r=n.buffer,o=a(t);o.pattern=t,e((0,g.eventChannel)(F,r||y.buffers.fixed(),o))}function I(n,e){e(!!$.isCancelled)}function q(n,e){n.flush(e)}function D(n,e,r,u){var a,c,f;return r._deferredEnd=null,c={},i(c,d.TASK,!0),i(c,"id",n),i(c,"name",e),a="done",f={},f[a]=f[a]||{},f[a].get=function(){if(r._deferredEnd)return r._deferredEnd.promise;var n=(0,d.deferred)();return r._deferredEnd=n,r._isRunning||(r._error?n.reject(r._error):n.resolve(r._result)),n.promise},i(c,"cont",u),i(c,"joiners",[]),i(c,"cancel",t),i(c,"isRunning",function(){return r._isRunning}),i(c,"isCancelled",function(){return r._isCancelled}),i(c,"isAborted",function(){return r._isAborted}),i(c,"result",function(){return r._result}),i(c,"error",function(){return r._error}),o(c,f),c}var F=arguments.length<=1||void 0===arguments[1]?function(){return d.noop}:arguments[1],H=arguments.length<=2||void 0===arguments[2]?d.noop:arguments[2],K=arguments.length<=3||void 0===arguments[3]?d.noop:arguments[3],B=arguments.length<=4||void 0===arguments[4]?{}:arguments[4],V=arguments.length<=5||void 0===arguments[5]?0:arguments[5],G=arguments.length<=6||void 0===arguments[6]?"anonymous":arguments[6],W=arguments[7];(0,d.check)(n,d.is.iterator,m);var J=B.sagaMonitor,z=B.logger,Q=B.onError,X=z||d.log,Y=(0,g.stdChannel)(F);r.cancel=d.noop;var Z=D(V,G,n,W),$={name:G,cancel:e,isRunning:!0},nn=c(G,$,v);return W&&(W.cancel=t),n._isRunning=!0,r(),Z}Object.defineProperty(e,"__esModule",{value:!0}),e.TASK_CANCEL=e.CHANNEL_END=e.NOT_ITERATOR_ERROR=void 0,e.default=s;var d=t(1),v=t(7),h=r(v),p=t(4),g=t(3),y=t(2),b=!1,m=e.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",E=(0,d.autoInc)(),k=e.CHANNEL_END={toString:function(){return"@@redux-saga/CHANNEL_END"}},_=e.TASK_CANCEL={toString:function(){return"@@redux-saga/TASK_CANCEL"}},O={wildcard:function(){return d.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)}}}},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(4);Object.defineProperty(e,"take",{enumerable:!0,get:function(){return r.take}}),Object.defineProperty(e,"takem",{enumerable:!0,get:function(){return r.takem}}),Object.defineProperty(e,"put",{enumerable:!0,get:function(){return r.put}}),Object.defineProperty(e,"race",{enumerable:!0,get:function(){return r.race}}),Object.defineProperty(e,"call",{enumerable:!0,get:function(){return r.call}}),Object.defineProperty(e,"apply",{enumerable:!0,get:function(){return r.apply}}),Object.defineProperty(e,"cps",{enumerable:!0,get:function(){return r.cps}}),Object.defineProperty(e,"fork",{enumerable:!0,get:function(){return r.fork}}),Object.defineProperty(e,"spawn",{enumerable:!0,get:function(){return r.spawn}}),Object.defineProperty(e,"join",{enumerable:!0,get:function(){return r.join}}),Object.defineProperty(e,"cancel",{enumerable:!0,get:function(){return r.cancel}}),Object.defineProperty(e,"select",{enumerable:!0,get:function(){return r.select}}),Object.defineProperty(e,"actionChannel",{enumerable:!0,get:function(){return r.actionChannel}}),Object.defineProperty(e,"cancelled",{enumerable:!0,get:function(){return r.cancelled}}),Object.defineProperty(e,"flush",{enumerable:!0,get:function(){return r.flush}})},function(n,e){"use strict";function t(n){o?r.push(n):(o=!0,r.push(n),t.flush())}Object.defineProperty(e,"__esModule",{value:!0}),e.default=t;var r=[],o=!1;t.suspend=function(){return o=!0},t.flush=function(){for(var n=void 0;n=r.shift();)n();o=!1}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function o(){function n(n){function r(n){for(var t=arguments.length,r=Array(t>1?t-1:0),c=1;c<t;c++)r[c-1]=arguments[c];return(0,a.default)(n.apply(void 0,r),i.subscribe,u,o,e,0,n.name)}var o=n.getState,u=n.dispatch;t=r;var i=(0,c.emitter)();return function(n){return function(e){var t=n(e);return i.emit(e),t}}}var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=void 0;if(u.is.func(e))throw new Error("Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead");if(e.logger&&!u.is.func(e.logger))throw new Error("`options.logger` passed to the Saga middleware is not a function!");if(e.onerror&&!u.is.func(e.onerror))throw new Error("`options.onerror` passed to the Saga middleware is not a function!");return n.run=function(n){for(var e=arguments.length,r=Array(e>1?e-1:0),o=1;o<e;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)(n,u.is.func,"sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!"),t.apply(void 0,[n].concat(r))},n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var u=t(1),i=t(5),a=r(i),c=t(3)},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function o(n,e){var t=e.subscribe,r=e.dispatch,o=e.getState,i=e.sagaMonitor,c=e.logger;return(0,u.check)(n,u.is.iterator,"runSaga must be called on an iterator"),(0,a.default)(n,t,r,o,{sagaMonitor:i,logger:c})}Object.defineProperty(e,"__esModule",{value:!0}),e.runSaga=o;var u=t(1),i=t(5),a=r(i)},function(n,e,t){"use strict";function r(n,e){function t(e,t){if(u===h)return v;if(t)throw u=h,t;o&&o(e);var r=n[u](),i=c(r,3),a=i[0],f=i[1],l=i[2];return u=a,o=l,u===h?v:f}var r=arguments.length<=2||void 0===arguments[2]?"iterator":arguments[2],o=void 0,u=e;return(0,l.makeIterator)(t,function(n){return t(null,n)},r,!0)}function o(n){return Array.isArray(n)?String(n.map(function(n){return String(n)})):String(n)}function u(n,e){for(var t=arguments.length,u=Array(t>2?t-2:0),i=2;i<t;i++)u[i-2]=arguments[i];var a={done:!1,value:(0,s.take)(n)},c=function(n){return{done:!1,value:s.fork.apply(void 0,[e].concat(u,[n]))}},l=void 0,d=function(n){return l=n};return r({q1:function(){return["q2",a,d]},q2:function(){return l===f.END?[h]:["q1",c(l)]}},"q1","takeEvery("+o(n)+", "+e.name+")")}function i(n,e){for(var t=arguments.length,u=Array(t>2?t-2:0),i=2;i<t;i++)u[i-2]=arguments[i];var a={done:!1,value:(0,s.take)(n)},c=function(n){return{done:!1,value:s.fork.apply(void 0,[e].concat(u,[n]))}},l=function(n){return{done:!1,value:(0,s.cancel)(n)}},d=void 0,v=void 0,p=function(n){return d=n},g=function(n){return v=n};return r({q1:function(){return["q2",a,g]},q2:function(){return v===f.END?[h]:d?["q3",l(d)]:["q1",c(v),p]},q3:function(){return["q1",c(v),p]}},"q1","takeLatest("+o(n)+", "+e.name+")")}function a(n,e,t){for(var u=arguments.length,i=Array(u>3?u-3:0),a=3;a<u;a++)i[a-3]=arguments[a];var c=void 0,v=void 0,p={done:!1,value:(0,s.actionChannel)(e,d.buffers.sliding(1))},g=function(){return{done:!1,value:(0,s.take)(v,e)}},y=function(n){return{done:!1,value:s.fork.apply(void 0,[t].concat(i,[n]))}},b={done:!1,value:(0,s.call)(l.delay,n)},m=function(n){return c=n},E=function(n){return v=n};return r({q1:function(){return["q2",p,E]},q2:function(){return["q3",g(),m]},q3:function(){return c===f.END?[h]:["q4",y(c)]},q4:function(){return["q2",b]}},"q1","throttle("+o(e)+", "+t.name+")")}Object.defineProperty(e,"__esModule",{value:!0});var c=function(){function n(n,e){var t=[],r=!0,o=!1,u=void 0;try{for(var i,a=n[Symbol.iterator]();!(r=(i=a.next()).done)&&(t.push(i.value),!e||t.length!==e);r=!0);}catch(c){o=!0,u=c}finally{try{!r&&a.return&&a.return()}finally{if(o)throw u}}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")}}();e.takeEvery=u,e.takeLatest=i,e.throttle=a;var f=t(3),l=t(1),s=t(4),d=t(2),v={done:!0,value:void 0},h={}},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(1);Object.defineProperty(e,"TASK",{enumerable:!0,get:function(){return r.TASK}}),Object.defineProperty(e,"noop",{enumerable:!0,get:function(){return r.noop}}),Object.defineProperty(e,"is",{enumerable:!0,get:function(){return r.is}}),Object.defineProperty(e,"deferred",{enumerable:!0,get:function(){return r.deferred}}),Object.defineProperty(e,"arrayOfDeffered",{enumerable:!0,get:function(){return r.arrayOfDeffered}}),Object.defineProperty(e,"createMockTask",{enumerable:!0,get:function(){return r.createMockTask}});var o=t(4);Object.defineProperty(e,"asEffect",{enumerable:!0,get:function(){return o.asEffect}})}])}); | ||
!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 o=t[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.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 o(n){return n&&n.__esModule?n:{"default":n}}Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.effects=e.CANCEL=e.delay=e.throttle=e.takeLatest=e.takeEvery=e.buffers=e.channel=e.eventChannel=e.END=e.runSaga=void 0;var u=t(9);Object.defineProperty(e,"runSaga",{enumerable:!0,get:function(){return u.runSaga}});var a=t(3);Object.defineProperty(e,"END",{enumerable:!0,get:function(){return a.END}}),Object.defineProperty(e,"eventChannel",{enumerable:!0,get:function(){return a.eventChannel}}),Object.defineProperty(e,"channel",{enumerable:!0,get:function(){return a.channel}});var i=t(2);Object.defineProperty(e,"buffers",{enumerable:!0,get:function(){return i.buffers}});var c=t(10);Object.defineProperty(e,"takeEvery",{enumerable:!0,get:function(){return c.takeEvery}}),Object.defineProperty(e,"takeLatest",{enumerable:!0,get:function(){return c.takeLatest}}),Object.defineProperty(e,"throttle",{enumerable:!0,get:function(){return c.throttle}});var f=t(1);Object.defineProperty(e,"delay",{enumerable:!0,get:function(){return f.delay}}),Object.defineProperty(e,"CANCEL",{enumerable:!0,get:function(){return f.CANCEL}});var l=t(8),s=o(l),d=t(7),v=r(d),p=t(11),g=r(p);e.default=s.default,e.effects=v,e.utils=g},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,t){if(!e(n))throw s("error","uncaught at check",t),new Error(t)}function o(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=v({},n),t=new Promise(function(n,t){e.resolve=n,e.reject=t});return e.promise=t,e}function a(n){for(var e=[],t=0;t<n;t++)e.push(u());return e}function i(n){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=void 0,r=new Promise(function(r){t=setTimeout(function(){return r(e)},n)});return r[b]=function(){return clearTimeout(t)},r}function c(){var n,e=!0,r=void 0,o=void 0;return n={},t(n,h,!0),t(n,"isRunning",function(){return e}),t(n,"result",function(){return r}),t(n,"error",function(){return o}),t(n,"setRunning",function(n){return e=n}),t(n,"setResult",function(n){return r=n}),t(n,"setError",function(n){return o=n}),n}function f(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(){return++n}}function l(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments[3],o={name:t,next:n,"throw":e,"return":_};return r&&(o[y]=!0),"undefined"!=typeof Symbol&&(o[Symbol.iterator]=function(){return o}),o}function s(n,e,t){"undefined"==typeof window?console.log("redux-saga "+n+": "+e+"\n"+(t&&t.stack||t)):console[n](e,t)}function d(n){return function(e){var t=Object.defineProperty(e,m,{value:!0});return n(t)}}Object.defineProperty(e,"__esModule",{value:!0});var v=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},p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};e.check=r,e.remove=o,e.deferred=u,e.arrayOfDeffered=a,e.delay=i,e.createMockTask=c,e.autoInc=f,e.makeIterator=l,e.log=s,e.wrapSagaDispatch=d;var g=e.sym=function(n){return"@@redux-saga/"+n},h=e.TASK=g("TASK"),y=e.HELPER=g("HELPER"),b=(e.MATCH=g("MATCH"),e.CANCEL=g("cancelPromise")),m=e.SAGA_ACTION=g("SAGA_ACTION"),E=e.konst=function(n){return function(){return n}},k=(e.kTrue=E(!0),e.kFalse=E(!1),e.noop=function(){},e.ident=function(n){return n},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},number:function(n){return"number"==typeof n},array:Array.isArray,promise:function(n){return n&&k.func(n.then)},iterator:function(n){return n&&k.func(n.next)&&k.func(n.throw)},task:function(n){return n&&n[h]},observable:function(n){return n&&k.func(n.subscribe)},buffer:function(n){return n&&k.func(n.isEmpty)&&k.func(n.take)&&k.func(n.put)},pattern:function(n){return n&&("string"==typeof n||"symbol"===("undefined"==typeof n?"undefined":p(n))||k.func(n)||k.array(n))},channel:function(n){return n&&k.func(n.take)&&k.func(n.close)},helper:function(n){return n&&n[y]}}),O=(e.uid=f(),function(n){throw n}),_=function(n){return{value:n,done:!0}};e.internalErr=function(n){return new Error("\n redux-saga: Error checking hooks detected an inconsistent 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: "+n+"\n")}},function(n,e,t){"use strict";function r(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments[1],t=new Array(n),r=0,o=0,i=0,l=function(e){t[o]=e,o=(o+1)%n,r++},s=function(){if(0!=r){var e=t[i];return t[i]=null,r--,i=(i+1)%n,e}},d=function(){for(var n=[];r;)n.push(s());return n};return{isEmpty:function(){return 0==r},put:function(s){if(r<n)l(s);else{var v=void 0;switch(e){case a:throw new Error(u);case c:t[o]=s,o=(o+1)%n,i=o;break;case f:v=2*n,t=d(),r=t.length,o=t.length,i=0,t.length=v,n=v,l(s)}}},take:s,flush:d}}Object.defineProperty(e,"__esModule",{value:!0}),e.buffers=e.BUFFER_OVERFLOW=void 0;var o=t(1),u=e.BUFFER_OVERFLOW="Channel's Buffer overflow!",a=1,i=2,c=3,f=4,l={isEmpty:o.kTrue,put:o.noop,take:o.noop};e.buffers={none:function(){return l},fixed:function(n){return r(n,a)},dropping:function(n){return r(n,i)},sliding:function(n){return r(n,c)},expanding:function(n){return r(n,f)}}},function(n,e,t){"use strict";function r(){function n(n){return t.push(n),function(){return(0,c.remove)(t,n)}}function e(n){for(var e=t.slice(),r=0,o=e.length;r<o;r++)e[r](n)}var t=[];return{subscribe:n,emit:e}}function o(){function n(){if(a&&i.length)throw(0,c.internalErr)("Cannot have a closed channel with pending takers");if(i.length&&!u.isEmpty())throw(0,c.internalErr)("Cannot have pending takers with non empty buffer")}function e(e){if(n(),(0,c.check)(e,c.is.notUndef,p),!a){if(!i.length)return u.put(e);for(var t=0;t<i.length;t++){var r=i[t];if(!r[c.MATCH]||r[c.MATCH](e))return i.splice(t,1),r(e)}}}function t(e){n(),(0,c.check)(e,c.is.func,"channel.take's callback must be a function"),a&&u.isEmpty()?e(s):u.isEmpty()?(i.push(e),e.cancel=function(){return(0,c.remove)(i,e)}):e(u.take())}function r(e){return n(),(0,c.check)(e,c.is.func,"channel.flush' callback must be a function"),a&&u.isEmpty()?void e(s):void e(u.flush())}function o(){if(n(),!a&&(a=!0,i.length)){var e=i;i=[];for(var t=0,r=e.length;t<r;t++)e[t](s)}}var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f.buffers.fixed(),a=!1,i=[];return(0,c.check)(u,c.is.buffer,v),{take:t,put:e,flush:r,close:o,get __takers__(){return i},get __closed__(){return a}}}function u(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:f.buffers.none(),t=arguments[2];arguments.length>2&&(0,c.check)(t,c.is.func,"Invalid match function passed to eventChannel");var r=o(e),u=n(function(n){d(n)?r.close():t&&!t(n)||r.put(n)});if(!c.is.func(u))throw new Error("in eventChannel: subscribe should return a function to unsubscribe");return{take:r.take,flush:r.flush,close:function(){r.__closed__||(r.close(),u())}}}function a(n){var e=u(n);return i({},e,{take:function(n,t){arguments.length>1&&((0,c.check)(t,c.is.func,"channel.take's matcher argument must be a function"),n[c.MATCH]=t),e.take(n)}})}Object.defineProperty(e,"__esModule",{value:!0}),e.UNDEFINED_INPUT_ERROR=e.INVALID_BUFFER=e.isEnd=e.END=void 0;var i=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};e.emitter=r,e.channel=o,e.eventChannel=u,e.stdChannel=a;var c=t(1),f=t(2),l="@@redux-saga/CHANNEL_END",s=e.END={type:l},d=e.isEnd=function(n){return n&&n.type===l},v=e.INVALID_BUFFER="invalid buffer passed to channel factory function",p=e.UNDEFINED_INPUT_ERROR="Saga was provided with an undefined action"},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 o(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*";if(arguments.length&&(0,k.check)(arguments[0],k.is.notUndef,"take(patternOrChannel): patternOrChannel is undefined"),k.is.pattern(n))return M(_,{pattern:n});if(k.is.channel(n))return M(_,{channel:n});throw new Error("take(patternOrChannel): argument "+String(n)+" is not valid channel or a valid pattern")}function u(){var n=o.apply(void 0,arguments);return n[_].maybe=!0,n}function a(n,e){return arguments.length>1?((0,k.check)(n,k.is.notUndef,"put(channel, action): argument channel is undefined"),(0,k.check)(n,k.is.channel,"put(channel, action): argument "+n+" is not a valid channel"),(0,k.check)(e,k.is.notUndef,"put(channel, action): argument action is undefined")):((0,k.check)(n,k.is.notUndef,"put(action): argument action is undefined"),e=n,n=null),M(A,{channel:n,action:e})}function i(n){return M(j,n)}function c(n,e,t){(0,k.check)(e,k.is.notUndef,n+": argument fn is undefined");var r=null;if(k.is.array(e)){var o=e,u=E(o,2);r=u[0],e=u[1]}else if(e.fn){var a=e;r=a.context,e=a.fn}return(0,k.check)(e,k.is.func,n+": argument "+e+" is not a function"),{context:r,fn:e,args:t}}function f(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return M(C,c("call",n,t))}function l(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return M(C,c("apply",{context:n,fn:e},t))}function s(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return M(w,c("cps",n,t))}function d(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return M(P,c("fork",n,t))}function v(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];var o=d.apply(void 0,[n].concat(t));return o[P].detached=!0,o}function p(n){if((0,k.check)(n,k.is.notUndef,"join(task): argument task is undefined"),!I(n))throw new Error("join(task): argument "+n+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return M(N,n)}function g(n){if((0,k.check)(n,k.is.notUndef,"cancel(task): argument task is undefined"),!I(n))throw new Error("cancel(task): argument "+n+" is not a valid Task object \n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)");return M(S,n)}function h(n){for(var e=arguments.length,t=Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return 0===arguments.length?n=k.ident:((0,k.check)(n,k.is.notUndef,"select(selector,[...]): argument selector is undefined"),(0,k.check)(n,k.is.func,"select(selector,[...]): argument "+n+" is not a function")),M(T,{selector:n,args:t})}function y(n,e){return(0,k.check)(n,k.is.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&((0,k.check)(e,k.is.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),(0,k.check)(e,k.is.notUndef,"actionChannel(pattern, buffer): argument "+e+" is not a valid buffer")),M(R,{pattern:n,buffer:e})}function b(){return M(x,{})}function m(n){return(0,k.check)(n,k.is.channel,"flush(channel): argument "+n+" is not valid channel"),M(U,n)}Object.defineProperty(e,"__esModule",{value:!0}),e.asEffect=void 0;var E=function(){function n(n,e){var t=[],r=!0,o=!1,u=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){o=!0,u=c}finally{try{!r&&i.return&&i.return()}finally{if(o)throw u}}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")}}();e.take=o,e.takem=u,e.put=a,e.race=i,e.call=f,e.apply=l,e.cps=s,e.fork=d,e.spawn=v,e.join=p,e.cancel=g,e.select=h,e.actionChannel=y,e.cancelled=b,e.flush=m;var k=t(1),O=(0,k.sym)("IO"),_="TAKE",A="PUT",j="RACE",C="CALL",w="CPS",P="FORK",N="JOIN",S="CANCEL",T="SELECT",R="ACTION_CHANNEL",x="CANCELLED",U="FLUSH",M=function(n,e){var t;return t={},r(t,O,!0),r(t,n,e),t};a.sync=function(){var n=a.apply(void 0,arguments);return n[A].sync=!0,n};var I=function(n){return n[k.TASK]};e.asEffect={take:function(n){return n&&n[O]&&n[_]},put:function(n){return n&&n[O]&&n[A]},race:function(n){return n&&n[O]&&n[j]},call:function(n){return n&&n[O]&&n[C]},cps:function(n){return n&&n[O]&&n[w]},fork:function(n){return n&&n[O]&&n[P]},join:function(n){return n&&n[O]&&n[N]},cancel:function(n){return n&&n[O]&&n[S]},select:function(n){return n&&n[O]&&n[T]},actionChannel:function(n){return n&&n[O]&&n[R]},cancelled:function(n){return n&&n[O]&&n[x]},flush:function(n){return n&&n[O]&&n[U]}}},function(n,e,t){"use strict";function r(n,e){for(var t in e){var r=e[t];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,t,r)}return n}function o(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 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 a(n){return("*"===n?E.wildcard:s.is.array(n)?E.array:s.is.func(n)?E.predicate:E.default)(n)}function i(n,e,t){function r(n){u(),t(n,!0)}function o(n){a.push(n),n.cont=function(o,u){c||((0,s.remove)(a,n),n.cont=s.noop,u?r(o):(n===e&&(i=o),a.length||(c=!0,t(i))))}}function u(){c||(c=!0,a.forEach(function(n){n.cont=s.noop,n.cancel()}),a=[])}var a=[],i=void 0,c=!1;return o(e),{addTask:o,cancelAll:u,abort:r,getTasks:function(){return a},taskNames:function(){return a.map(function(n){return n.name})}}}function c(n){var e=n.context,t=n.fn,r=n.args;if(s.is.iterator(t))return t;var o=void 0,u=void 0;try{o=t.apply(e,r)}catch(a){u=a}return s.is.iterator(o)?o:u?(0,s.makeIterator)(function(){throw u}):(0,s.makeIterator)(function(){var n=void 0,e={done:!1,value:o},t=function(n){return{done:!0,value:n}};return function(r){return n?t(r):(n=!0,e)}}())}function f(n){return{fn:n}}function l(n){function e(){Z.isRunning&&!Z.isCancelled&&(Z.isCancelled=!0,E(m))}function t(){n._isRunning&&!n._isCancelled&&(n._isCancelled=!0,$.cancelAll(),k(m))}function E(e,t){if(!Z.isRunning)throw new Error("Trying to resume an already finished generator");try{var r=void 0;t?r=n.throw(e):e===m?(Z.isCancelled=!0,E.cancel(),r=s.is.func(n.return)?n.return(m):{done:!0,value:m}):r=e===b?s.is.func(n.return)?n.return():{done:!0}:n.next(e),r.done?(Z.isMainRunning=!1,Z.cont&&Z.cont(r.value)):O(r.value,G,"",E)}catch(o){Z.isCancelled&&Q("error","uncaught at "+B,o.message),Z.isMainRunning=!1,Z.cont(o,!0)}}function k(e,t){n._isRunning=!1,X.close(),t?(e instanceof Error&&(e.sagaStack="at "+B+" \n "+(e.sagaStack||e.stack)),Y.cont||(Q("error","uncaught",e.sagaStack||e.stack),e instanceof Error&&z&&z(e)),n._error=e,n._isAborted=!0,n._deferredEnd&&n._deferredEnd.reject(e)):(e===m&&h&&Q("info",B+" has been cancelled",""),n._result=e,n._deferredEnd&&n._deferredEnd.resolve(e)),Y.cont&&Y.cont(e,t),Y.joiners.forEach(function(n){return n.cb(e,t)}),Y.joiners=null}function O(n,e){function t(n,e){a||(a=!0,o.cancel=s.noop,W&&(e?W.effectRejected(u,n):W.effectResolved(u,n)),o(n,e))}var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments[3],u=(0,s.uid)();W&&W.effectTriggered({effectId:u,parentEffectId:e,label:r,effect:n});var a=void 0;t.cancel=s.noop,o.cancel=function(){if(!a){a=!0;try{t.cancel()}catch(n){Q("error","uncaught at "+B,n.message)}t.cancel=s.noop,W&&W.effectCancelled(u)}};var i=void 0;return s.is.promise(n)?_(n,t):s.is.helper(n)?N(f(n),u,t):s.is.iterator(n)?A(n,u,B,t):s.is.array(n)?R(n,u,t):s.is.notUndef(i=v.asEffect.take(n))?j(i,t):s.is.notUndef(i=v.asEffect.put(n))?C(i,t):s.is.notUndef(i=v.asEffect.race(n))?x(i,u,t):s.is.notUndef(i=v.asEffect.call(n))?w(i,u,t):s.is.notUndef(i=v.asEffect.cps(n))?P(i,t):s.is.notUndef(i=v.asEffect.fork(n))?N(i,u,t):s.is.notUndef(i=v.asEffect.join(n))?S(i,t):s.is.notUndef(i=v.asEffect.cancel(n))?T(i,t):s.is.notUndef(i=v.asEffect.select(n))?U(i,t):s.is.notUndef(i=v.asEffect.actionChannel(n))?M(i,t):s.is.notUndef(i=v.asEffect.flush(n))?L(i,t):s.is.notUndef(i=v.asEffect.cancelled(n))?I(i,t):t(n)}function _(n,e){var t=n[s.CANCEL];"function"==typeof t&&(e.cancel=t),n.then(e,function(n){return e(n,!0)})}function A(n,e,t,r){l(n,q,H,F,K,e,t,r)}function j(n,e){var t=n.channel,r=n.pattern,o=n.maybe;t=t||X;var u=function(n){return n instanceof Error?e(n,!0):e((0,p.isEnd)(n)&&!o?b:n)};try{t.take(u,a(r))}catch(i){return e(i,!0)}e.cancel=u.cancel}function C(n,e){var t=n.channel,r=n.action,o=n.sync;(0,d.asap)(function(){var n=void 0;try{n=(t?t.put:H)(r)}catch(u){if(t||o)return e(u,!0);Q("error","uncaught at "+B,u.stack||u.message||u)}return o&&s.is.promise(n)?void _(n,e):e(n)})}function w(n,e,t){var r=n.context,o=n.fn,u=n.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)?A(a,e,o.name,t):t(a)}function P(n,e){var t=n.context,r=n.fn,o=n.args;try{!function(){var n=function(n,t){return s.is.undef(n)?e(t):e(n,!0)};r.apply(t,o.concat(n)),n.cancel&&(e.cancel=function(){return n.cancel()})}()}catch(u){return e(u,!0)}}function N(n,e,t){var r=n.context,o=n.fn,u=n.args,a=n.detached,i=c({context:r,fn:o,args:u});try{(0,d.suspend)();var f=l(i,q,H,F,K,e,o.name,a?null:s.noop);a?t(f):i._isRunning?($.addTask(f),t(f)):i._error?$.abort(i._error):t(f)}finally{(0,d.flush)()}}function S(n,e){n.isRunning()?!function(){var t={task:Y,cb:e};e.cancel=function(){return(0,s.remove)(n.joiners,t)},n.joiners.push(t)}():n.isAborted()?e(n.error(),!0):e(n.result())}function T(n,e){n.isRunning()&&n.cancel(),e()}function R(n,e,t){function r(){o===a.length&&(u=!0,t(a))}if(!n.length)return t([]);var o=0,u=void 0,a=Array(n.length),i=n.map(function(n,e){var i=function(n,i){u||(i||(0,p.isEnd)(n)||n===b||n===m?(t.cancel(),t(n,i)):(a[e]=n,o++,r()))};return i.cancel=s.noop,i});t.cancel=function(){u||(u=!0,i.forEach(function(n){return n.cancel()}))},n.forEach(function(n,t){return O(n,e,t,i[t])})}function x(n,e,t){var r=void 0,o=Object.keys(n),a={};o.forEach(function(n){var e=function(e,o){r||(o?(t.cancel(),t(e,!0)):(0,p.isEnd)(e)||e===b||e===m||(t.cancel(),r=!0,t(u({},n,e))))};e.cancel=s.noop,a[n]=e}),t.cancel=function(){r||(r=!0,o.forEach(function(n){return a[n].cancel()}))},o.forEach(function(t){r||O(n[t],e,t,a[t])})}function U(n,e){var t=n.selector,r=n.args;try{var u=t.apply(void 0,[F()].concat(o(r)));e(u)}catch(a){e(a,!0)}}function M(n,e){var t=n.pattern,r=n.buffer,o=a(t);o.pattern=t,e((0,p.eventChannel)(q,r||g.buffers.fixed(),o))}function I(n,e){e(!!Z.isCancelled)}function L(n,e){n.flush(e)}function D(n,e,o,a){var i,c,f;return o._deferredEnd=null,c={},u(c,s.TASK,!0),u(c,"id",n),u(c,"name",e),i="done",f={},f[i]=f[i]||{},f[i].get=function(){if(o._deferredEnd)return o._deferredEnd.promise;var n=(0,s.deferred)();return o._deferredEnd=n,o._isRunning||(o._error?n.reject(o._error):n.resolve(o._result)),n.promise},u(c,"cont",a),u(c,"joiners",[]),u(c,"cancel",t),u(c,"isRunning",function(){return o._isRunning}),u(c,"isCancelled",function(){return o._isCancelled}),u(c,"isAborted",function(){return o._isAborted}),u(c,"result",function(){return o._result}),u(c,"error",function(){return o._error}),r(c,f),c}var q=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return s.noop},H=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.noop,F=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.noop,K=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},G=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,B=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"anonymous",V=arguments[7];(0,s.check)(n,s.is.iterator,y);var W=K.sagaMonitor,J=K.logger,z=K.onError,Q=J||s.log,X=(0,p.stdChannel)(q);E.cancel=s.noop;var Y=D(G,B,n,V),Z={name:B,cancel:e,isRunning:!0},$=i(B,Z,k);return V&&(V.cancel=t),n._isRunning=!0,E(),Y}Object.defineProperty(e,"__esModule",{value:!0}),e.TASK_CANCEL=e.CHANNEL_END=e.NOT_ITERATOR_ERROR=void 0,e.default=l;var s=t(1),d=t(6),v=t(4),p=t(3),g=t(2),h=!1,y=e.NOT_ITERATOR_ERROR="proc first argument (Saga function result) must be an iterator",b=e.CHANNEL_END={toString:function(){return"@@redux-saga/CHANNEL_END"}},m=e.TASK_CANCEL={toString:function(){return"@@redux-saga/TASK_CANCEL"}},E={wildcard:function(){return s.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)}}}},function(n,e){"use strict";function t(n){try{o(),n()}finally{u()}}function r(n){i?a.push(n):t(n)}function o(){i++}function u(){i--,!i&&a.length&&t(a.shift())}Object.defineProperty(e,"__esModule",{value:!0}),e.asap=r,e.suspend=o,e.flush=u;var a=[],i=0},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(4);Object.defineProperty(e,"take",{enumerable:!0,get:function(){return r.take}}),Object.defineProperty(e,"takem",{enumerable:!0,get:function(){return r.takem}}),Object.defineProperty(e,"put",{enumerable:!0,get:function(){return r.put}}),Object.defineProperty(e,"race",{enumerable:!0,get:function(){return r.race}}),Object.defineProperty(e,"call",{enumerable:!0,get:function(){return r.call}}),Object.defineProperty(e,"apply",{enumerable:!0,get:function(){return r.apply}}),Object.defineProperty(e,"cps",{enumerable:!0,get:function(){return r.cps}}),Object.defineProperty(e,"fork",{enumerable:!0,get:function(){return r.fork}}),Object.defineProperty(e,"spawn",{enumerable:!0,get:function(){return r.spawn}}),Object.defineProperty(e,"join",{enumerable:!0,get:function(){return r.join}}),Object.defineProperty(e,"cancel",{enumerable:!0,get:function(){return r.cancel}}),Object.defineProperty(e,"select",{enumerable:!0,get:function(){return r.select}}),Object.defineProperty(e,"actionChannel",{enumerable:!0,get:function(){return r.actionChannel}}),Object.defineProperty(e,"cancelled",{enumerable:!0,get:function(){return r.cancelled}}),Object.defineProperty(e,"flush",{enumerable:!0,get:function(){return r.flush}})},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function o(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 u(){function n(n){function u(n,t,r){return(0,c.default)(n.apply(void 0,o(t)),d.subscribe,v,i,e,r,n.name)}var i=n.getState,s=n.dispatch;t=u;var d=(0,l.emitter)(),v=(0,a.wrapSagaDispatch)(s);return function(n){return function(e){r&&r.actionDispatched(e);var t=n(e);return e[a.SAGA_ACTION]?d.emit(e):(0,f.asap)(function(){return d.emit(e)}),t}}}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=void 0,r=e.sagaMonitor;if(a.is.func(e))throw new Error("Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead");if(e.logger&&!a.is.func(e.logger))throw new Error("`options.logger` passed to the Saga middleware is not a function!");if(e.onerror&&!a.is.func(e.onerror))throw new Error("`options.onerror` passed to the Saga middleware is not a function!");return n.run=function(n){for(var e=arguments.length,o=Array(e>1?e-1:0),u=1;u<e;u++)o[u-1]=arguments[u];(0,a.check)(t,a.is.notUndef,"Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware"),(0,a.check)(n,a.is.func,"sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!");var i=(0,a.uid)();r&&r.effectTriggered({effectId:i,root:!0,parentEffectId:0,effect:{root:!0,saga:n,args:o}});var c=t(n,o,i);return r&&r.effectResolved(i,c),c},n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var a=t(1),i=t(5),c=r(i),f=t(6),l=t(3)},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function o(n,e){var t=e.subscribe,r=e.dispatch,o=e.getState,a=e.sagaMonitor,c=e.logger;(0,u.check)(n,u.is.iterator,"runSaga must be called on an iterator");var f=(0,u.uid)();a&&(r=(0,u.wrapSagaDispatch)(r),a.effectTriggered({effectId:f,root:!0,parentEffectId:0,effect:{root:!0,saga:n,args:[]}}));var l=(0,i.default)(n,t,r,o,{sagaMonitor:a,logger:c},f,n.name);return a&&a.effectResolved(f,l),l}Object.defineProperty(e,"__esModule",{value:!0}),e.runSaga=o;var u=t(1),a=t(5),i=r(a)},function(n,e,t){"use strict";function r(n,e){function t(e,t){if(u===p)return v;if(t)throw u=p,t;o&&o(e);var r=n[u](),a=c(r,3),i=a[0],f=a[1],l=a[2];return u=i,o=l,u===p?v:f}var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"iterator",o=void 0,u=e;return(0,l.makeIterator)(t,function(n){return t(null,n)},r,!0)}function o(n){return Array.isArray(n)?String(n.map(function(n){return String(n)})):String(n)}function u(n,e){for(var t=arguments.length,u=Array(t>2?t-2:0),a=2;a<t;a++)u[a-2]=arguments[a];var i={done:!1,value:(0,s.take)(n)},c=function(n){return{done:!1,value:s.fork.apply(void 0,[e].concat(u,[n]))}},l=void 0,d=function(n){return l=n};return r({q1:function(){return["q2",i,d]},q2:function(){return l===f.END?[p]:["q1",c(l)]}},"q1","takeEvery("+o(n)+", "+e.name+")")}function a(n,e){for(var t=arguments.length,u=Array(t>2?t-2:0),a=2;a<t;a++)u[a-2]=arguments[a];var i={done:!1,value:(0,s.take)(n)},c=function(n){return{done:!1,value:s.fork.apply(void 0,[e].concat(u,[n]))}},l=function(n){return{done:!1,value:(0,s.cancel)(n)}},d=void 0,v=void 0,g=function(n){return d=n},h=function(n){return v=n};return r({q1:function(){return["q2",i,h]},q2:function(){return v===f.END?[p]:d?["q3",l(d)]:["q1",c(v),g]},q3:function(){return["q1",c(v),g]}},"q1","takeLatest("+o(n)+", "+e.name+")")}function i(n,e,t){for(var u=arguments.length,a=Array(u>3?u-3:0),i=3;i<u;i++)a[i-3]=arguments[i];var c=void 0,v=void 0,g={done:!1,value:(0,s.actionChannel)(e,d.buffers.sliding(1))},h=function(){return{done:!1,value:(0,s.take)(v,e)}},y=function(n){return{done:!1,value:s.fork.apply(void 0,[t].concat(a,[n]))}},b={done:!1,value:(0,s.call)(l.delay,n)},m=function(n){return c=n},E=function(n){return v=n};return r({q1:function(){return["q2",g,E]},q2:function(){return["q3",h(),m]},q3:function(){return c===f.END?[p]:["q4",y(c)]},q4:function(){return["q2",b]}},"q1","throttle("+o(e)+", "+t.name+")")}Object.defineProperty(e,"__esModule",{value:!0});var c=function(){function n(n,e){var t=[],r=!0,o=!1,u=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){o=!0,u=c}finally{try{!r&&i.return&&i.return()}finally{if(o)throw u}}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")}}();e.takeEvery=u,e.takeLatest=a,e.throttle=i;var f=t(3),l=t(1),s=t(4),d=t(2),v={done:!0,value:void 0},p={}},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(1);Object.defineProperty(e,"TASK",{enumerable:!0,get:function(){return r.TASK}}),Object.defineProperty(e,"SAGA_ACTION",{enumerable:!0,get:function(){return r.SAGA_ACTION}}),Object.defineProperty(e,"noop",{enumerable:!0,get:function(){return r.noop}}),Object.defineProperty(e,"is",{enumerable:!0,get:function(){return r.is}}),Object.defineProperty(e,"deferred",{enumerable:!0,get:function(){return r.deferred}}),Object.defineProperty(e,"arrayOfDeffered",{enumerable:!0,get:function(){return r.arrayOfDeffered}}),Object.defineProperty(e,"createMockTask",{enumerable:!0,get:function(){return r.createMockTask}});var o=t(4);Object.defineProperty(e,"CHANNEL_END",{enumerable:!0,get:function(){return o.CHANNEL_END}}),Object.defineProperty(e,"asEffect",{enumerable:!0,get:function(){return o.asEffect}})}])}); |
@@ -0,0 +0,0 @@ import {Action} from "redux"; |
@@ -13,3 +13,3 @@ import { kTrue, noop } from './utils'; | ||
function ringBuffer() { | ||
var limit = arguments.length <= 0 || arguments[0] === undefined ? 10 : arguments[0]; | ||
var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; | ||
var overflowAction = arguments[1]; | ||
@@ -16,0 +16,0 @@ |
@@ -43,3 +43,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
export function channel() { | ||
var buffer = arguments.length <= 0 || arguments[0] === undefined ? buffers.fixed() : arguments[0]; | ||
var buffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : buffers.fixed(); | ||
@@ -129,3 +129,3 @@ var closed = false; | ||
export function eventChannel(subscribe) { | ||
var buffer = arguments.length <= 1 || arguments[1] === undefined ? buffers.none() : arguments[1]; | ||
var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : buffers.none(); | ||
var matcher = arguments[2]; | ||
@@ -132,0 +132,0 @@ |
@@ -28,3 +28,3 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
export function take() { | ||
var patternOrChannel = arguments.length <= 0 || arguments[0] === undefined ? '*' : arguments[0]; | ||
var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*'; | ||
@@ -102,3 +102,3 @@ if (arguments.length) { | ||
export function apply(context, fn) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
@@ -105,0 +105,0 @@ return effect(CALL, getFnCallDesc('apply', { context: context, fn: fn }, args)); |
@@ -1,10 +0,15 @@ | ||
import { is, check } from './utils'; | ||
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); } } | ||
import { is, check, uid as nextSagaId, wrapSagaDispatch, SAGA_ACTION } from './utils'; | ||
import proc from './proc'; | ||
import { asap } from './scheduler'; | ||
import { emitter } from './channel'; | ||
export default function sagaMiddlewareFactory() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var runSagaDynamically = void 0; | ||
var sagaMonitor = options.sagaMonitor; | ||
if (is.func(options)) { | ||
@@ -27,14 +32,11 @@ if (process.env.NODE_ENV === 'production') { | ||
function sagaMiddleware(_ref) { | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState, | ||
dispatch = _ref.dispatch; | ||
runSagaDynamically = runSaga; | ||
var sagaEmitter = emitter(); | ||
var sagaDispatch = wrapSagaDispatch(dispatch); | ||
function runSaga(saga) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return proc(saga.apply(undefined, args), sagaEmitter.subscribe, dispatch, getState, options, 0, saga.name); | ||
function runSaga(saga, args, sagaId) { | ||
return proc(saga.apply(undefined, _toConsumableArray(args)), sagaEmitter.subscribe, sagaDispatch, getState, options, sagaId, saga.name); | ||
} | ||
@@ -44,4 +46,15 @@ | ||
return function (action) { | ||
if (sagaMonitor) { | ||
sagaMonitor.actionDispatched(action); | ||
} | ||
var result = next(action); // hit reducers | ||
sagaEmitter.emit(action); | ||
if (action[SAGA_ACTION]) { | ||
// Saga actions are already scheduled with asap in proc/runPutEffect | ||
sagaEmitter.emit(action); | ||
} else { | ||
asap(function () { | ||
return sagaEmitter.emit(action); | ||
}); | ||
} | ||
return result; | ||
@@ -53,4 +66,4 @@ }; | ||
sagaMiddleware.run = function (saga) { | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
@@ -60,3 +73,12 @@ | ||
check(saga, is.func, 'sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!'); | ||
return runSagaDynamically.apply(undefined, [saga].concat(args)); | ||
var effectId = nextSagaId(); | ||
if (sagaMonitor) { | ||
sagaMonitor.effectTriggered({ effectId: effectId, root: true, parentEffectId: 0, effect: { root: true, saga: saga, args: args } }); | ||
} | ||
var task = runSagaDynamically(saga, args, effectId); | ||
if (sagaMonitor) { | ||
sagaMonitor.effectResolved(effectId, task); | ||
} | ||
return task; | ||
}; | ||
@@ -63,0 +85,0 @@ |
@@ -7,4 +7,4 @@ function _defineEnumerableProperties(obj, descs) { for (var key in descs) { var desc = descs[key]; desc.configurable = desc.enumerable = true; if ("value" in desc) desc.writable = true; Object.defineProperty(obj, key, desc); } return obj; } | ||
import { noop, kTrue, is, log as _log, check, deferred, autoInc, remove, TASK, CANCEL, makeIterator } from './utils'; | ||
import asap from './asap'; | ||
import { noop, kTrue, is, log as _log, check, deferred, uid as nextEffectId, remove, TASK, CANCEL, makeIterator } from './utils'; | ||
import { asap, suspend, flush } from './scheduler'; | ||
import { asEffect } from './io'; | ||
@@ -18,3 +18,2 @@ import { stdChannel as _stdChannel, eventChannel, isEnd } from './channel'; | ||
var nextEffectId = autoInc(); | ||
export var CHANNEL_END = { | ||
@@ -136,5 +135,5 @@ toString: function toString() { | ||
function createTaskIterator(_ref) { | ||
var context = _ref.context; | ||
var fn = _ref.fn; | ||
var args = _ref.args; | ||
var context = _ref.context, | ||
fn = _ref.fn, | ||
args = _ref.args; | ||
@@ -187,10 +186,10 @@ if (is.iterator(fn)) { | ||
export default function proc(iterator) { | ||
var subscribe = arguments.length <= 1 || arguments[1] === undefined ? function () { | ||
var subscribe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { | ||
return noop; | ||
} : arguments[1]; | ||
var dispatch = arguments.length <= 2 || arguments[2] === undefined ? noop : arguments[2]; | ||
var getState = arguments.length <= 3 || arguments[3] === undefined ? noop : arguments[3]; | ||
var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; | ||
var parentEffectId = arguments.length <= 5 || arguments[5] === undefined ? 0 : arguments[5]; | ||
var name = arguments.length <= 6 || arguments[6] === undefined ? 'anonymous' : arguments[6]; | ||
}; | ||
var dispatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop; | ||
var getState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop; | ||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; | ||
var parentEffectId = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; | ||
var name = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'anonymous'; | ||
var cont = arguments[7]; | ||
@@ -200,5 +199,5 @@ | ||
var sagaMonitor = options.sagaMonitor; | ||
var logger = options.logger; | ||
var onError = options.onError; | ||
var sagaMonitor = options.sagaMonitor, | ||
logger = options.logger, | ||
onError = options.onError; | ||
@@ -235,5 +234,5 @@ var log = logger || _log; | ||
cancel all pending tasks (including the main task), then end the current task. | ||
Cancellation propagates down to the whole execution tree holded by this Parent task | ||
Cancellation propagates down to the whole execution tree holded by this Parent task | ||
It's also propagated to all joiners of this task and their execution tree/joiners | ||
Cancellation is noop for terminated/Cancelled tasks tasks | ||
Cancellation is noop for terminated/Cancelled tasks tasks | ||
**/ | ||
@@ -288,3 +287,3 @@ function cancel() { | ||
We can get this value here | ||
- By cancelling the parent task manually | ||
- By cancelling the parent task manually | ||
- By joining a Cancelled task | ||
@@ -358,3 +357,3 @@ **/ | ||
function runEffect(effect, parentEffectId) { | ||
var label = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2]; | ||
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
var cb = arguments[3]; | ||
@@ -415,8 +414,8 @@ | ||
it allows this generator to propagate cancellation downward. | ||
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod] | ||
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod] | ||
And the setup must occur before calling the callback | ||
This is a sort of inversion of control: called async functions are responsible | ||
This is a sort of inversion of control: called async functions are responsible | ||
of completing the flow by calling the provided continuation; while caller functions | ||
are responsible for aborting the current flow by calling the attached cancel function | ||
Library users can attach their own cancellation logic to promises by defining a | ||
Library users can attach their own cancellation logic to promises by defining a | ||
promise[CANCEL] method in their returned promises | ||
@@ -450,5 +449,5 @@ ATTENTION! calling cancel must have no effect on an already completed or cancelled effect | ||
function runTakeEffect(_ref2, cb) { | ||
var channel = _ref2.channel; | ||
var pattern = _ref2.pattern; | ||
var maybe = _ref2.maybe; | ||
var channel = _ref2.channel, | ||
pattern = _ref2.pattern, | ||
maybe = _ref2.maybe; | ||
@@ -468,12 +467,11 @@ channel = channel || stdChannel; | ||
function runPutEffect(_ref3, cb) { | ||
var channel = _ref3.channel; | ||
var action = _ref3.action; | ||
var sync = _ref3.sync; | ||
var channel = _ref3.channel, | ||
action = _ref3.action, | ||
sync = _ref3.sync; | ||
/* | ||
Use a reentrant lock `asap` to flatten all nested dispatches | ||
If this put cause another Saga to take this action an then immediately | ||
put an action that will be taken by this Saga. Then the outer Saga will miss | ||
the action from the inner Saga b/c this put has not yet returned. | ||
*/ | ||
/** | ||
Schedule the put in case another saga is holding a lock. | ||
The put will be executed atomically. ie nested puts will execute after | ||
this put has terminated. | ||
**/ | ||
asap(function () { | ||
@@ -499,5 +497,5 @@ var result = void 0; | ||
function runCallEffect(_ref4, effectId, cb) { | ||
var context = _ref4.context; | ||
var fn = _ref4.fn; | ||
var args = _ref4.args; | ||
var context = _ref4.context, | ||
fn = _ref4.fn, | ||
args = _ref4.args; | ||
@@ -515,5 +513,5 @@ var result = void 0; | ||
function runCPSEffect(_ref5, cb) { | ||
var context = _ref5.context; | ||
var fn = _ref5.fn; | ||
var args = _ref5.args; | ||
var context = _ref5.context, | ||
fn = _ref5.fn, | ||
args = _ref5.args; | ||
@@ -542,25 +540,28 @@ // CPS (ie node style functions) can define their own cancellation logic | ||
function runForkEffect(_ref6, effectId, cb) { | ||
var context = _ref6.context; | ||
var fn = _ref6.fn; | ||
var args = _ref6.args; | ||
var detached = _ref6.detached; | ||
var context = _ref6.context, | ||
fn = _ref6.fn, | ||
args = _ref6.args, | ||
detached = _ref6.detached; | ||
var taskIterator = createTaskIterator({ context: context, fn: fn, args: args }); | ||
asap.suspend(); | ||
var task = proc(taskIterator, subscribe, dispatch, getState, options, effectId, fn.name, detached ? null : noop); | ||
try { | ||
suspend(); | ||
var _task = proc(taskIterator, subscribe, dispatch, getState, options, effectId, fn.name, detached ? null : noop); | ||
if (detached) { | ||
cb(task); | ||
} else { | ||
if (taskIterator._isRunning) { | ||
taskQueue.addTask(task); | ||
cb(task); | ||
} else if (taskIterator._error) { | ||
taskQueue.abort(taskIterator._error); | ||
if (detached) { | ||
cb(_task); | ||
} else { | ||
cb(task); | ||
if (taskIterator._isRunning) { | ||
taskQueue.addTask(_task); | ||
cb(_task); | ||
} else if (taskIterator._error) { | ||
taskQueue.abort(taskIterator._error); | ||
} else { | ||
cb(_task); | ||
} | ||
} | ||
} finally { | ||
flush(); | ||
} | ||
asap.flush(); | ||
// Fork effects are non cancellables | ||
@@ -682,4 +683,4 @@ } | ||
function runSelectEffect(_ref7, cb) { | ||
var selector = _ref7.selector; | ||
var args = _ref7.args; | ||
var selector = _ref7.selector, | ||
args = _ref7.args; | ||
@@ -695,4 +696,4 @@ try { | ||
function runChannelEffect(_ref8, cb) { | ||
var pattern = _ref8.pattern; | ||
var buffer = _ref8.buffer; | ||
var pattern = _ref8.pattern, | ||
buffer = _ref8.buffer; | ||
@@ -699,0 +700,0 @@ var match = matcher(pattern); |
@@ -1,10 +0,10 @@ | ||
import { is, check } from './utils'; | ||
import { is, check, uid as nextSagaId, wrapSagaDispatch } from './utils'; | ||
import proc from './proc'; | ||
export function runSaga(iterator, _ref) { | ||
var subscribe = _ref.subscribe; | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
var sagaMonitor = _ref.sagaMonitor; | ||
var logger = _ref.logger; | ||
var subscribe = _ref.subscribe, | ||
dispatch = _ref.dispatch, | ||
getState = _ref.getState, | ||
sagaMonitor = _ref.sagaMonitor, | ||
logger = _ref.logger; | ||
@@ -14,3 +14,14 @@ | ||
return proc(iterator, subscribe, dispatch, getState, { sagaMonitor: sagaMonitor, logger: logger }); | ||
var effectId = nextSagaId(); | ||
if (sagaMonitor) { | ||
dispatch = wrapSagaDispatch(dispatch); | ||
sagaMonitor.effectTriggered({ effectId: effectId, root: true, parentEffectId: 0, effect: { root: true, saga: iterator, args: [] } }); | ||
} | ||
var task = proc(iterator, subscribe, dispatch, getState, { sagaMonitor: sagaMonitor, logger: logger }, effectId, iterator.name); | ||
if (sagaMonitor) { | ||
sagaMonitor.effectResolved(effectId, task); | ||
} | ||
return task; | ||
} |
@@ -12,3 +12,3 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
function fsmIterator(fsm, q0) { | ||
var name = arguments.length <= 2 || arguments[2] === undefined ? 'iterator' : arguments[2]; | ||
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'iterator'; | ||
@@ -29,10 +29,8 @@ var updateState = void 0, | ||
var _fsm$qNext = fsm[qNext](); | ||
var _fsm$qNext = fsm[qNext](), | ||
_fsm$qNext2 = _slicedToArray(_fsm$qNext, 3), | ||
q = _fsm$qNext2[0], | ||
output = _fsm$qNext2[1], | ||
_updateState = _fsm$qNext2[2]; | ||
var _fsm$qNext2 = _slicedToArray(_fsm$qNext, 3); | ||
var q = _fsm$qNext2[0]; | ||
var output = _fsm$qNext2[1]; | ||
var _updateState = _fsm$qNext2[2]; | ||
qNext = q; | ||
@@ -39,0 +37,0 @@ updateState = _updateState; |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -14,2 +14,3 @@ 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; } | ||
export var CANCEL = sym('cancelPromise'); | ||
export var SAGA_ACTION = sym('SAGA_ACTION'); | ||
export var konst = function konst(v) { | ||
@@ -82,3 +83,3 @@ return function () { | ||
export function deferred() { | ||
var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -103,3 +104,3 @@ var def = _extends({}, props); | ||
export function delay(ms) { | ||
var val = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; | ||
var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
@@ -143,3 +144,3 @@ var timeoutId = void 0; | ||
export function autoInc() { | ||
var seed = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; | ||
var seed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
@@ -151,2 +152,4 @@ return function () { | ||
export var uid = autoInc(); | ||
var kThrow = function kThrow(err) { | ||
@@ -159,4 +162,4 @@ throw err; | ||
export function makeIterator(next) { | ||
var thro = arguments.length <= 1 || arguments[1] === undefined ? kThrow : arguments[1]; | ||
var name = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2]; | ||
var thro = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : kThrow; | ||
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
var isHelper = arguments[3]; | ||
@@ -193,2 +196,9 @@ | ||
return new Error('\n redux-saga: Error checking hooks detected an inconsistent 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: ' + err + '\n'); | ||
}; | ||
}; | ||
export function wrapSagaDispatch(dispatch) { | ||
return function sagaDispatch(action) { | ||
var wrappedAction = Object.defineProperty(action, SAGA_ACTION, { value: true }); | ||
return dispatch(wrappedAction); | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
export { TASK, noop, is, deferred, arrayOfDeffered, createMockTask } from './internal/utils'; | ||
export { asEffect } from './internal/io'; | ||
export { TASK, SAGA_ACTION, noop, is, deferred, arrayOfDeffered, createMockTask } from './internal/utils'; | ||
export { CHANNEL_END, asEffect } from './internal/io'; |
@@ -0,0 +0,0 @@ import {Middleware} from "redux"; |
@@ -20,3 +20,3 @@ 'use strict'; | ||
function ringBuffer() { | ||
var limit = arguments.length <= 0 || arguments[0] === undefined ? 10 : arguments[0]; | ||
var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; | ||
var overflowAction = arguments[1]; | ||
@@ -23,0 +23,0 @@ |
@@ -56,3 +56,3 @@ 'use strict'; | ||
function channel() { | ||
var buffer = arguments.length <= 0 || arguments[0] === undefined ? _buffers.buffers.fixed() : arguments[0]; | ||
var buffer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _buffers.buffers.fixed(); | ||
@@ -142,3 +142,3 @@ var closed = false; | ||
function eventChannel(subscribe) { | ||
var buffer = arguments.length <= 1 || arguments[1] === undefined ? _buffers.buffers.none() : arguments[1]; | ||
var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _buffers.buffers.none(); | ||
var matcher = arguments[2]; | ||
@@ -145,0 +145,0 @@ |
@@ -51,3 +51,3 @@ 'use strict'; | ||
function take() { | ||
var patternOrChannel = arguments.length <= 0 || arguments[0] === undefined ? '*' : arguments[0]; | ||
var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*'; | ||
@@ -125,3 +125,3 @@ if (arguments.length) { | ||
function apply(context, fn) { | ||
var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
@@ -128,0 +128,0 @@ return effect(CALL, getFnCallDesc('apply', { context: context, fn: fn }, args)); |
@@ -14,2 +14,4 @@ 'use strict'; | ||
var _scheduler = require('./scheduler'); | ||
var _channel = require('./channel'); | ||
@@ -19,7 +21,11 @@ | ||
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 sagaMiddlewareFactory() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var runSagaDynamically = void 0; | ||
var sagaMonitor = options.sagaMonitor; | ||
if (_utils.is.func(options)) { | ||
@@ -42,14 +48,11 @@ if (process.env.NODE_ENV === 'production') { | ||
function sagaMiddleware(_ref) { | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState, | ||
dispatch = _ref.dispatch; | ||
runSagaDynamically = runSaga; | ||
var sagaEmitter = (0, _channel.emitter)(); | ||
var sagaDispatch = (0, _utils.wrapSagaDispatch)(dispatch); | ||
function runSaga(saga) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return (0, _proc2.default)(saga.apply(undefined, args), sagaEmitter.subscribe, dispatch, getState, options, 0, saga.name); | ||
function runSaga(saga, args, sagaId) { | ||
return (0, _proc2.default)(saga.apply(undefined, _toConsumableArray(args)), sagaEmitter.subscribe, sagaDispatch, getState, options, sagaId, saga.name); | ||
} | ||
@@ -59,4 +62,15 @@ | ||
return function (action) { | ||
if (sagaMonitor) { | ||
sagaMonitor.actionDispatched(action); | ||
} | ||
var result = next(action); // hit reducers | ||
sagaEmitter.emit(action); | ||
if (action[_utils.SAGA_ACTION]) { | ||
// Saga actions are already scheduled with asap in proc/runPutEffect | ||
sagaEmitter.emit(action); | ||
} else { | ||
(0, _scheduler.asap)(function () { | ||
return sagaEmitter.emit(action); | ||
}); | ||
} | ||
return result; | ||
@@ -68,4 +82,4 @@ }; | ||
sagaMiddleware.run = function (saga) { | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
@@ -75,3 +89,12 @@ | ||
(0, _utils.check)(saga, _utils.is.func, 'sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!'); | ||
return runSagaDynamically.apply(undefined, [saga].concat(args)); | ||
var effectId = (0, _utils.uid)(); | ||
if (sagaMonitor) { | ||
sagaMonitor.effectTriggered({ effectId: effectId, root: true, parentEffectId: 0, effect: { root: true, saga: saga, args: args } }); | ||
} | ||
var task = runSagaDynamically(saga, args, effectId); | ||
if (sagaMonitor) { | ||
sagaMonitor.effectResolved(effectId, task); | ||
} | ||
return task; | ||
}; | ||
@@ -78,0 +101,0 @@ |
@@ -11,6 +11,4 @@ 'use strict'; | ||
var _asap = require('./asap'); | ||
var _scheduler = require('./scheduler'); | ||
var _asap2 = _interopRequireDefault(_asap); | ||
var _io = require('./io'); | ||
@@ -22,4 +20,2 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineEnumerableProperties(obj, descs) { for (var key in descs) { var desc = descs[key]; desc.configurable = desc.enumerable = true; if ("value" in desc) desc.writable = true; Object.defineProperty(obj, key, desc); } return obj; } | ||
@@ -35,3 +31,2 @@ | ||
var nextEffectId = (0, _utils.autoInc)(); | ||
var CHANNEL_END = exports.CHANNEL_END = { | ||
@@ -153,5 +148,5 @@ toString: function toString() { | ||
function createTaskIterator(_ref) { | ||
var context = _ref.context; | ||
var fn = _ref.fn; | ||
var args = _ref.args; | ||
var context = _ref.context, | ||
fn = _ref.fn, | ||
args = _ref.args; | ||
@@ -204,10 +199,10 @@ if (_utils.is.iterator(fn)) { | ||
function proc(iterator) { | ||
var subscribe = arguments.length <= 1 || arguments[1] === undefined ? function () { | ||
var subscribe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { | ||
return _utils.noop; | ||
} : arguments[1]; | ||
var dispatch = arguments.length <= 2 || arguments[2] === undefined ? _utils.noop : arguments[2]; | ||
var getState = arguments.length <= 3 || arguments[3] === undefined ? _utils.noop : arguments[3]; | ||
var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; | ||
var parentEffectId = arguments.length <= 5 || arguments[5] === undefined ? 0 : arguments[5]; | ||
var name = arguments.length <= 6 || arguments[6] === undefined ? 'anonymous' : arguments[6]; | ||
}; | ||
var dispatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _utils.noop; | ||
var getState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _utils.noop; | ||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; | ||
var parentEffectId = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; | ||
var name = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'anonymous'; | ||
var cont = arguments[7]; | ||
@@ -217,5 +212,5 @@ | ||
var sagaMonitor = options.sagaMonitor; | ||
var logger = options.logger; | ||
var onError = options.onError; | ||
var sagaMonitor = options.sagaMonitor, | ||
logger = options.logger, | ||
onError = options.onError; | ||
@@ -252,5 +247,5 @@ var log = logger || _utils.log; | ||
cancel all pending tasks (including the main task), then end the current task. | ||
Cancellation propagates down to the whole execution tree holded by this Parent task | ||
Cancellation propagates down to the whole execution tree holded by this Parent task | ||
It's also propagated to all joiners of this task and their execution tree/joiners | ||
Cancellation is noop for terminated/Cancelled tasks tasks | ||
Cancellation is noop for terminated/Cancelled tasks tasks | ||
**/ | ||
@@ -305,3 +300,3 @@ function cancel() { | ||
We can get this value here | ||
- By cancelling the parent task manually | ||
- By cancelling the parent task manually | ||
- By joining a Cancelled task | ||
@@ -375,6 +370,6 @@ **/ | ||
function runEffect(effect, parentEffectId) { | ||
var label = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2]; | ||
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
var cb = arguments[3]; | ||
var effectId = nextEffectId(); | ||
var effectId = (0, _utils.uid)(); | ||
sagaMonitor && sagaMonitor.effectTriggered({ effectId: effectId, parentEffectId: parentEffectId, label: label, effect: effect }); | ||
@@ -432,8 +427,8 @@ | ||
it allows this generator to propagate cancellation downward. | ||
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod] | ||
ATTENTION! effect runners must setup the cancel logic by setting cb.cancel = [cancelMethod] | ||
And the setup must occur before calling the callback | ||
This is a sort of inversion of control: called async functions are responsible | ||
This is a sort of inversion of control: called async functions are responsible | ||
of completing the flow by calling the provided continuation; while caller functions | ||
are responsible for aborting the current flow by calling the attached cancel function | ||
Library users can attach their own cancellation logic to promises by defining a | ||
Library users can attach their own cancellation logic to promises by defining a | ||
promise[CANCEL] method in their returned promises | ||
@@ -467,5 +462,5 @@ ATTENTION! calling cancel must have no effect on an already completed or cancelled effect | ||
function runTakeEffect(_ref2, cb) { | ||
var channel = _ref2.channel; | ||
var pattern = _ref2.pattern; | ||
var maybe = _ref2.maybe; | ||
var channel = _ref2.channel, | ||
pattern = _ref2.pattern, | ||
maybe = _ref2.maybe; | ||
@@ -485,13 +480,12 @@ channel = channel || stdChannel; | ||
function runPutEffect(_ref3, cb) { | ||
var channel = _ref3.channel; | ||
var action = _ref3.action; | ||
var sync = _ref3.sync; | ||
var channel = _ref3.channel, | ||
action = _ref3.action, | ||
sync = _ref3.sync; | ||
/* | ||
Use a reentrant lock `asap` to flatten all nested dispatches | ||
If this put cause another Saga to take this action an then immediately | ||
put an action that will be taken by this Saga. Then the outer Saga will miss | ||
the action from the inner Saga b/c this put has not yet returned. | ||
*/ | ||
(0, _asap2.default)(function () { | ||
/** | ||
Schedule the put in case another saga is holding a lock. | ||
The put will be executed atomically. ie nested puts will execute after | ||
this put has terminated. | ||
**/ | ||
(0, _scheduler.asap)(function () { | ||
var result = void 0; | ||
@@ -516,5 +510,5 @@ try { | ||
function runCallEffect(_ref4, effectId, cb) { | ||
var context = _ref4.context; | ||
var fn = _ref4.fn; | ||
var args = _ref4.args; | ||
var context = _ref4.context, | ||
fn = _ref4.fn, | ||
args = _ref4.args; | ||
@@ -532,5 +526,5 @@ var result = void 0; | ||
function runCPSEffect(_ref5, cb) { | ||
var context = _ref5.context; | ||
var fn = _ref5.fn; | ||
var args = _ref5.args; | ||
var context = _ref5.context, | ||
fn = _ref5.fn, | ||
args = _ref5.args; | ||
@@ -559,25 +553,28 @@ // CPS (ie node style functions) can define their own cancellation logic | ||
function runForkEffect(_ref6, effectId, cb) { | ||
var context = _ref6.context; | ||
var fn = _ref6.fn; | ||
var args = _ref6.args; | ||
var detached = _ref6.detached; | ||
var context = _ref6.context, | ||
fn = _ref6.fn, | ||
args = _ref6.args, | ||
detached = _ref6.detached; | ||
var taskIterator = createTaskIterator({ context: context, fn: fn, args: args }); | ||
_asap2.default.suspend(); | ||
var task = proc(taskIterator, subscribe, dispatch, getState, options, effectId, fn.name, detached ? null : _utils.noop); | ||
try { | ||
(0, _scheduler.suspend)(); | ||
var _task = proc(taskIterator, subscribe, dispatch, getState, options, effectId, fn.name, detached ? null : _utils.noop); | ||
if (detached) { | ||
cb(task); | ||
} else { | ||
if (taskIterator._isRunning) { | ||
taskQueue.addTask(task); | ||
cb(task); | ||
} else if (taskIterator._error) { | ||
taskQueue.abort(taskIterator._error); | ||
if (detached) { | ||
cb(_task); | ||
} else { | ||
cb(task); | ||
if (taskIterator._isRunning) { | ||
taskQueue.addTask(_task); | ||
cb(_task); | ||
} else if (taskIterator._error) { | ||
taskQueue.abort(taskIterator._error); | ||
} else { | ||
cb(_task); | ||
} | ||
} | ||
} finally { | ||
(0, _scheduler.flush)(); | ||
} | ||
_asap2.default.flush(); | ||
// Fork effects are non cancellables | ||
@@ -699,4 +696,4 @@ } | ||
function runSelectEffect(_ref7, cb) { | ||
var selector = _ref7.selector; | ||
var args = _ref7.args; | ||
var selector = _ref7.selector, | ||
args = _ref7.args; | ||
@@ -712,4 +709,4 @@ try { | ||
function runChannelEffect(_ref8, cb) { | ||
var pattern = _ref8.pattern; | ||
var buffer = _ref8.buffer; | ||
var pattern = _ref8.pattern, | ||
buffer = _ref8.buffer; | ||
@@ -716,0 +713,0 @@ var match = matcher(pattern); |
@@ -17,7 +17,7 @@ 'use strict'; | ||
function runSaga(iterator, _ref) { | ||
var subscribe = _ref.subscribe; | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
var sagaMonitor = _ref.sagaMonitor; | ||
var logger = _ref.logger; | ||
var subscribe = _ref.subscribe, | ||
dispatch = _ref.dispatch, | ||
getState = _ref.getState, | ||
sagaMonitor = _ref.sagaMonitor, | ||
logger = _ref.logger; | ||
@@ -27,3 +27,14 @@ | ||
return (0, _proc2.default)(iterator, subscribe, dispatch, getState, { sagaMonitor: sagaMonitor, logger: logger }); | ||
var effectId = (0, _utils.uid)(); | ||
if (sagaMonitor) { | ||
dispatch = (0, _utils.wrapSagaDispatch)(dispatch); | ||
sagaMonitor.effectTriggered({ effectId: effectId, root: true, parentEffectId: 0, effect: { root: true, saga: iterator, args: [] } }); | ||
} | ||
var task = (0, _proc2.default)(iterator, subscribe, dispatch, getState, { sagaMonitor: sagaMonitor, logger: logger }, effectId, iterator.name); | ||
if (sagaMonitor) { | ||
sagaMonitor.effectResolved(effectId, task); | ||
} | ||
return task; | ||
} |
@@ -25,3 +25,3 @@ 'use strict'; | ||
function fsmIterator(fsm, q0) { | ||
var name = arguments.length <= 2 || arguments[2] === undefined ? 'iterator' : arguments[2]; | ||
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'iterator'; | ||
@@ -42,10 +42,8 @@ var updateState = void 0, | ||
var _fsm$qNext = fsm[qNext](); | ||
var _fsm$qNext = fsm[qNext](), | ||
_fsm$qNext2 = _slicedToArray(_fsm$qNext, 3), | ||
q = _fsm$qNext2[0], | ||
output = _fsm$qNext2[1], | ||
_updateState = _fsm$qNext2[2]; | ||
var _fsm$qNext2 = _slicedToArray(_fsm$qNext, 3); | ||
var q = _fsm$qNext2[0]; | ||
var output = _fsm$qNext2[1]; | ||
var _updateState = _fsm$qNext2[2]; | ||
qNext = q; | ||
@@ -52,0 +50,0 @@ updateState = _updateState; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -21,2 +21,3 @@ exports.check = check; | ||
exports.log = log; | ||
exports.wrapSagaDispatch = wrapSagaDispatch; | ||
@@ -32,2 +33,3 @@ 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; } | ||
var CANCEL = exports.CANCEL = sym('cancelPromise'); | ||
var SAGA_ACTION = exports.SAGA_ACTION = sym('SAGA_ACTION'); | ||
var konst = exports.konst = function konst(v) { | ||
@@ -100,3 +102,3 @@ return function () { | ||
function deferred() { | ||
var props = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -121,3 +123,3 @@ var def = _extends({}, props); | ||
function delay(ms) { | ||
var val = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; | ||
var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
@@ -161,3 +163,3 @@ var timeoutId = void 0; | ||
function autoInc() { | ||
var seed = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; | ||
var seed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
@@ -169,2 +171,4 @@ return function () { | ||
var uid = exports.uid = autoInc(); | ||
var kThrow = function kThrow(err) { | ||
@@ -177,4 +181,4 @@ throw err; | ||
function makeIterator(next) { | ||
var thro = arguments.length <= 1 || arguments[1] === undefined ? kThrow : arguments[1]; | ||
var name = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2]; | ||
var thro = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : kThrow; | ||
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
var isHelper = arguments[3]; | ||
@@ -211,2 +215,9 @@ | ||
return new Error('\n redux-saga: Error checking hooks detected an inconsistent 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: ' + err + '\n'); | ||
}; | ||
}; | ||
function wrapSagaDispatch(dispatch) { | ||
return function sagaDispatch(action) { | ||
var wrappedAction = Object.defineProperty(action, SAGA_ACTION, { value: true }); | ||
return dispatch(wrappedAction); | ||
}; | ||
} |
@@ -15,2 +15,8 @@ 'use strict'; | ||
}); | ||
Object.defineProperty(exports, 'SAGA_ACTION', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utils.SAGA_ACTION; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'noop', { | ||
@@ -49,2 +55,8 @@ enumerable: true, | ||
Object.defineProperty(exports, 'CHANNEL_END', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.CHANNEL_END; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'asEffect', { | ||
@@ -51,0 +63,0 @@ enumerable: true, |
{ | ||
"name": "redux-saga", | ||
"version": "0.12.1", | ||
"version": "0.13.0", | ||
"description": "Saga middleware for Redux to handle Side Effects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# 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) [![CDNJS](https://img.shields.io/cdnjs/v/redux-saga.svg?style=flat-square)](https://cdnjs.com/libraries/redux-saga) | ||
@@ -5,0 +5,0 @@ Redux アプリケーションのための副作用ミドルウェア(非同期 Action)。`redux-thunk` ミドルウェアによって処理される Thunk(サンク) を送り出す代わりに、 |
# redux-saga | ||
[![npm version](https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/redux-saga.svg?style=flat-square)](https://cdnjs.com/libraries/redux-saga) | ||
@@ -5,0 +6,0 @@ 这是Redux应用的又一个副作用模型。可以用来替换redux-thunk中间件。通过创建 *Sagas* 去搜集所有的副作用逻辑到一个集中过的地方。 |
# redux-saga | ||
[![npm version](https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/redux-saga.svg?style=flat-square)](https://cdnjs.com/libraries/redux-saga) | ||
@@ -5,0 +6,0 @@ Redux 應用程式的另一種 Side Effect 模型。代替 redux-thunk 發送的 thunk。你可以在一個地方建立 *Sagas* 來集中所有的 Side Effect 邏輯。 |
# 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) [![CDNJS](https://img.shields.io/cdnjs/v/redux-saga.svg?style=flat-square)](https://cdnjs.com/libraries/redux-saga) | ||
@@ -5,0 +5,0 @@ `redux-saga` is a library that aims to make side effects (i.e. asynchronous things like data fetching and impure things like accessing the browser cache) in React/Redux applications easier and better. |
export { take, takem, put, race, call, apply, cps, fork, spawn, join, cancel, select, actionChannel, cancelled, flush } from './internal/io' |
@@ -0,0 +0,0 @@ import middleware from './internal/middleware' |
@@ -0,0 +0,0 @@ import { kTrue, noop } from './utils' |
@@ -0,0 +0,0 @@ import { is, check, remove, MATCH, internalErr} from './utils' |
@@ -0,0 +0,0 @@ import { sym, is, ident, check, TASK } from './utils' |
@@ -1,9 +0,10 @@ | ||
import { is, check } from './utils' | ||
import { is, check, uid as nextSagaId, wrapSagaDispatch, SAGA_ACTION } from './utils' | ||
import proc from './proc' | ||
import { asap } from './scheduler' | ||
import {emitter} from './channel' | ||
export default function sagaMiddlewareFactory(options = {}) { | ||
let runSagaDynamically | ||
const {sagaMonitor} = options | ||
@@ -40,11 +41,12 @@ if(is.func(options)) { | ||
const sagaEmitter = emitter() | ||
const sagaDispatch = wrapSagaDispatch(dispatch) | ||
function runSaga(saga, ...args) { | ||
function runSaga(saga, args, sagaId) { | ||
return proc( | ||
saga(...args), | ||
sagaEmitter.subscribe, | ||
dispatch, | ||
sagaDispatch, | ||
getState, | ||
options, | ||
0, | ||
sagaId, | ||
saga.name | ||
@@ -55,4 +57,13 @@ ) | ||
return next => action => { | ||
if(sagaMonitor) { | ||
sagaMonitor.actionDispatched(action) | ||
} | ||
const result = next(action) // hit reducers | ||
sagaEmitter.emit(action) | ||
if(action[SAGA_ACTION]) { | ||
// Saga actions are already scheduled with asap in proc/runPutEffect | ||
sagaEmitter.emit(action) | ||
} else { | ||
asap(() => sagaEmitter.emit(action)) | ||
} | ||
return result | ||
@@ -65,3 +76,12 @@ } | ||
check(saga, is.func, 'sagaMiddleware.run(saga, ...args): saga argument must be a Generator function!') | ||
return runSagaDynamically(saga, ...args) | ||
const effectId = nextSagaId() | ||
if(sagaMonitor) { | ||
sagaMonitor.effectTriggered({effectId , root: true, parentEffectId: 0, effect: {root: true, saga, args}}) | ||
} | ||
const task = runSagaDynamically(saga, args, effectId) | ||
if(sagaMonitor) { | ||
sagaMonitor.effectResolved(effectId, task) | ||
} | ||
return task | ||
} | ||
@@ -68,0 +88,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { noop, kTrue, is, log as _log, check, deferred, autoInc, remove, TASK, CANCEL, makeIterator } from './utils' | ||
import asap from './asap' | ||
import { noop, kTrue, is, log as _log, check, deferred, uid as nextEffectId, remove, TASK, CANCEL, makeIterator } from './utils' | ||
import { asap, suspend, flush } from './scheduler' | ||
import { asEffect } from './io' | ||
@@ -11,3 +11,2 @@ import { stdChannel as _stdChannel, eventChannel, isEnd } from './channel' | ||
const nextEffectId = autoInc() | ||
export const CHANNEL_END = {toString() { return '@@redux-saga/CHANNEL_END' }} | ||
@@ -433,8 +432,7 @@ export const TASK_CANCEL = {toString() { return '@@redux-saga/TASK_CANCEL' }} | ||
function runPutEffect({channel, action, sync}, cb) { | ||
/* | ||
Use a reentrant lock `asap` to flatten all nested dispatches | ||
If this put cause another Saga to take this action an then immediately | ||
put an action that will be taken by this Saga. Then the outer Saga will miss | ||
the action from the inner Saga b/c this put has not yet returned. | ||
*/ | ||
/** | ||
Schedule the put in case another saga is holding a lock. | ||
The put will be executed atomically. ie nested puts will execute after | ||
this put has terminated. | ||
**/ | ||
asap(() => { | ||
@@ -493,18 +491,21 @@ let result | ||
asap.suspend() | ||
const task = proc(taskIterator, subscribe, dispatch, getState, options, effectId, fn.name, (detached ? null : noop)) | ||
try { | ||
suspend() | ||
const task = proc(taskIterator, subscribe, dispatch, getState, options, effectId, fn.name, (detached ? null : noop)) | ||
if(detached) { | ||
cb(task) | ||
} else { | ||
if(taskIterator._isRunning) { | ||
taskQueue.addTask(task) | ||
if(detached) { | ||
cb(task) | ||
} else if(taskIterator._error) { | ||
taskQueue.abort(taskIterator._error) | ||
} else { | ||
cb(task) | ||
if(taskIterator._isRunning) { | ||
taskQueue.addTask(task) | ||
cb(task) | ||
} else if(taskIterator._error) { | ||
taskQueue.abort(taskIterator._error) | ||
} else { | ||
cb(task) | ||
} | ||
} | ||
} finally { | ||
flush() | ||
} | ||
asap.flush() | ||
// Fork effects are non cancellables | ||
@@ -511,0 +512,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { is, check } from './utils' | ||
import { is, check, uid as nextSagaId, wrapSagaDispatch } from './utils' | ||
import proc from './proc' | ||
@@ -17,3 +17,8 @@ | ||
return proc( | ||
const effectId = nextSagaId() | ||
if(sagaMonitor) { | ||
dispatch = wrapSagaDispatch(dispatch) | ||
sagaMonitor.effectTriggered({effectId, root: true, parentEffectId: 0, effect: {root: true, saga: iterator, args:[]}}) | ||
} | ||
const task = proc( | ||
iterator, | ||
@@ -23,4 +28,12 @@ subscribe, | ||
getState, | ||
{sagaMonitor, logger} | ||
{sagaMonitor, logger}, | ||
effectId, | ||
iterator.name | ||
) | ||
if(sagaMonitor) { | ||
sagaMonitor.effectResolved(effectId, task) | ||
} | ||
return task | ||
} |
@@ -0,0 +0,0 @@ import { END } from './channel' |
@@ -6,2 +6,3 @@ export const sym = id => `@@redux-saga/${id}` | ||
export const CANCEL = sym('cancelPromise') | ||
export const SAGA_ACTION = sym('SAGA_ACTION') | ||
export const konst = v => () => v | ||
@@ -92,2 +93,4 @@ export const kTrue = konst(true) | ||
export const uid = autoInc() | ||
const kThrow = err => { throw err } | ||
@@ -126,1 +129,8 @@ const kReturn = value => ({value, done: true}) | ||
`) | ||
export function wrapSagaDispatch(dispatch) { | ||
return function sagaDispatch(action) { | ||
const wrappedAction = Object.defineProperty(action, SAGA_ACTION, { value: true }) | ||
return dispatch(wrappedAction) | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
export { TASK, noop, is, deferred, arrayOfDeffered, createMockTask } from './internal/utils' | ||
export { asEffect } from './internal/io' | ||
export { TASK, SAGA_ACTION, noop, is, deferred, arrayOfDeffered, createMockTask } from './internal/utils' | ||
export { CHANNEL_END, asEffect } from './internal/io' |
@@ -0,0 +0,0 @@ export type Predicate<T> = (arg: T) => boolean; |
@@ -0,0 +0,0 @@ import { |
module.exports = require('./lib/utils') |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
376783
6899
0