redux-saga
Advanced tools
Comparing version 0.15.6 to 0.16.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.ReduxSaga = global.ReduxSaga || {}))); | ||
(factory((global.ReduxSaga = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -25,4 +25,2 @@ | ||
var defineEnumerableProperties = function (obj, descs) { | ||
@@ -85,8 +83,8 @@ for (var key in descs) { | ||
var TASK = sym('TASK'); | ||
var HELPER = sym('HELPER'); | ||
var MATCH = sym('MATCH'); | ||
var CANCEL = sym('CANCEL_PROMISE'); | ||
var SAGA_ACTION = sym('SAGA_ACTION'); | ||
var SELF_CANCELLATION = sym('SELF_CANCELLATION'); | ||
var TASK = /*#__PURE__*/sym('TASK'); | ||
var HELPER = /*#__PURE__*/sym('HELPER'); | ||
var MATCH = /*#__PURE__*/sym('MATCH'); | ||
var CANCEL = /*#__PURE__*/sym('CANCEL_PROMISE'); | ||
var SAGA_ACTION = /*#__PURE__*/sym('SAGA_ACTION'); | ||
var SELF_CANCELLATION = /*#__PURE__*/sym('SELF_CANCELLATION'); | ||
var konst = function konst(v) { | ||
@@ -97,4 +95,4 @@ return function () { | ||
}; | ||
var kTrue = konst(true); | ||
var kTrue = /*#__PURE__*/konst(true); | ||
var kFalse = /*#__PURE__*/konst(false); | ||
var noop = function noop() {}; | ||
@@ -265,3 +263,3 @@ var ident = function ident(v) { | ||
var uid = autoInc(); | ||
var uid = /*#__PURE__*/autoInc(); | ||
@@ -878,3 +876,3 @@ var kThrow = function kThrow(err) { | ||
var IO = sym('IO'); | ||
var IO = /*#__PURE__*/sym('IO'); | ||
var TAKE = 'TAKE'; | ||
@@ -904,2 +902,8 @@ var PUT = 'PUT'; | ||
var detach = function detach(eff) { | ||
check(asEffect.fork(eff), is.object, 'detach(eff): argument must be a fork effect'); | ||
eff[FORK].detached = true; | ||
return eff; | ||
}; | ||
function take() { | ||
@@ -947,3 +951,3 @@ var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*'; | ||
put.sync = deprecate(put.resolve, updateIncentive('put.sync', 'put.resolve')); | ||
put.sync = /*#__PURE__*/deprecate(put.resolve, /*#__PURE__*/updateIncentive('put.sync', 'put.resolve')); | ||
@@ -1014,5 +1018,3 @@ function all(effects) { | ||
var eff = fork.apply(undefined, [fn].concat(args)); | ||
eff[FORK].detached = true; | ||
return eff; | ||
return detach(fork.apply(undefined, [fn].concat(args))); | ||
} | ||
@@ -1099,3 +1101,3 @@ | ||
function takeEvery$$1(patternOrChannel, worker) { | ||
function takeEvery(patternOrChannel, worker) { | ||
for (var _len8 = arguments.length, args = Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) { | ||
@@ -1108,3 +1110,3 @@ args[_key8 - 2] = arguments[_key8]; | ||
function takeLatest$$1(patternOrChannel, worker) { | ||
function takeLatest(patternOrChannel, worker) { | ||
for (var _len9 = arguments.length, args = Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) { | ||
@@ -1117,3 +1119,3 @@ args[_key9 - 2] = arguments[_key9]; | ||
function throttle$$1(ms, pattern, worker) { | ||
function throttle(ms, pattern, worker) { | ||
for (var _len10 = arguments.length, args = Array(_len10 > 3 ? _len10 - 3 : 0), _key10 = 3; _key10 < _len10; _key10++) { | ||
@@ -1133,17 +1135,17 @@ args[_key10 - 3] = arguments[_key10]; | ||
var asEffect = { | ||
take: createAsEffectType(TAKE), | ||
put: createAsEffectType(PUT), | ||
all: createAsEffectType(ALL), | ||
race: createAsEffectType(RACE), | ||
call: createAsEffectType(CALL), | ||
cps: createAsEffectType(CPS), | ||
fork: createAsEffectType(FORK), | ||
join: createAsEffectType(JOIN), | ||
cancel: createAsEffectType(CANCEL$1), | ||
select: createAsEffectType(SELECT), | ||
actionChannel: createAsEffectType(ACTION_CHANNEL), | ||
cancelled: createAsEffectType(CANCELLED), | ||
flush: createAsEffectType(FLUSH), | ||
getContext: createAsEffectType(GET_CONTEXT), | ||
setContext: createAsEffectType(SET_CONTEXT) | ||
take: /*#__PURE__*/createAsEffectType(TAKE), | ||
put: /*#__PURE__*/createAsEffectType(PUT), | ||
all: /*#__PURE__*/createAsEffectType(ALL), | ||
race: /*#__PURE__*/createAsEffectType(RACE), | ||
call: /*#__PURE__*/createAsEffectType(CALL), | ||
cps: /*#__PURE__*/createAsEffectType(CPS), | ||
fork: /*#__PURE__*/createAsEffectType(FORK), | ||
join: /*#__PURE__*/createAsEffectType(JOIN), | ||
cancel: /*#__PURE__*/createAsEffectType(CANCEL$1), | ||
select: /*#__PURE__*/createAsEffectType(SELECT), | ||
actionChannel: /*#__PURE__*/createAsEffectType(ACTION_CHANNEL), | ||
cancelled: /*#__PURE__*/createAsEffectType(CANCELLED), | ||
flush: /*#__PURE__*/createAsEffectType(FLUSH), | ||
getContext: /*#__PURE__*/createAsEffectType(GET_CONTEXT), | ||
setContext: /*#__PURE__*/createAsEffectType(SET_CONTEXT) | ||
}; | ||
@@ -1341,2 +1343,11 @@ | ||
var log$$1 = logger || log; | ||
var logError = function logError(err) { | ||
var message = err.sagaStack; | ||
if (!message && err.stack) { | ||
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : 'Error: ' + err.message + '\n' + err.stack; | ||
} | ||
log$$1('error', 'uncaught at ' + name, message || err.message || err); | ||
}; | ||
var stdChannel$$1 = stdChannel(subscribe); | ||
@@ -1455,3 +1466,3 @@ var taskContext = Object.create(parentContext); | ||
if (mainTask.isCancelled) { | ||
log$$1('error', 'uncaught at ' + name, error.message); | ||
logError(error); | ||
} | ||
@@ -1467,5 +1478,2 @@ mainTask.isMainRunning = false; | ||
if (!isErr) { | ||
if ("development" === 'development' && result === TASK_CANCEL) { | ||
log$$1('info', name + ' has been cancelled', ''); | ||
} | ||
iterator._result = result; | ||
@@ -1475,8 +1483,12 @@ iterator._deferredEnd && iterator._deferredEnd.resolve(result); | ||
if (result instanceof Error) { | ||
result.sagaStack = 'at ' + name + ' \n ' + (result.sagaStack || result.stack); | ||
Object.defineProperty(result, 'sagaStack', { | ||
value: 'at ' + name + ' \n ' + (result.sagaStack || result.stack), | ||
configurable: true | ||
}); | ||
} | ||
if (!task.cont) { | ||
log$$1('error', 'uncaught', result.sagaStack || result.stack); | ||
if (result instanceof Error && onError) { | ||
onError(result); | ||
} else { | ||
logError(result); | ||
} | ||
@@ -1541,3 +1553,3 @@ } | ||
} catch (err) { | ||
log$$1('error', 'uncaught at ' + name, err.message); | ||
logError(err); | ||
} | ||
@@ -1626,3 +1638,3 @@ currCb.cancel = noop; // defensive measure | ||
if (channel$$1 || resolve) return cb(error, true); | ||
log$$1('error', 'uncaught at ' + name, error.stack || error.message || error); | ||
logError(error); | ||
} | ||
@@ -1798,7 +1810,8 @@ | ||
} else if (!isEnd(res) && res !== CHANNEL_END && res !== TASK_CANCEL) { | ||
var _cb; | ||
var _response; | ||
cb.cancel(); | ||
completed = true; | ||
cb((_cb = {}, _cb[key] = res, _cb)); | ||
var response = (_response = {}, _response[key] = res, _response); | ||
cb(is.array(effects) ? [].slice.call(_extends({}, response, { length: keys.length })) : response); | ||
} | ||
@@ -2046,5 +2059,5 @@ }; | ||
setContext: setContext, | ||
takeEvery: takeEvery$$1, | ||
takeLatest: takeLatest$$1, | ||
throttle: throttle$$1 | ||
takeEvery: takeEvery, | ||
takeLatest: takeLatest, | ||
throttle: throttle | ||
}); | ||
@@ -2080,2 +2093,3 @@ | ||
exports.CANCEL = CANCEL; | ||
exports.detach = detach; | ||
@@ -2082,0 +2096,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.ReduxSaga=n.ReduxSaga||{})}(this,function(n){"use strict";function t(n,t,e){if(!t(n))throw f("error","uncaught at check",e),Error(e)}function e(n,t){return hn.notUndef(n)&&gn.call(n,t)}function r(n,t){var e=n.indexOf(t);0>e||n.splice(e,1)}function o(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=tn({},n),e=new Promise(function(n,e){t.resolve=n,t.reject=e});return t.promise=e,t}function u(n){for(var t=[],e=0;n>e;e++)t.push(o());return t}function a(n){var t=1>=arguments.length||void 0===arguments[1]||arguments[1],e=void 0,r=new Promise(function(r){e=setTimeout(function(){return r(t)},n)});return r[cn]=function(){return clearTimeout(e)},r}function i(){var n,t=!0,e=void 0,r=void 0;return n={},n[on]=!0,n.isRunning=function(){return t},n.result=function(){return e},n.error=function(){return r},n.setRunning=function(n){return t=n},n.setResult=function(n){return e=n},n.setError=function(n){return r=n},n}function c(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:bn,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments[3],o={name:e,next:n,throw:t,return:En};return r&&(o[un]=!0),"undefined"!=typeof Symbol&&(o[Symbol.iterator]=function(){return o}),o}function f(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";"undefined"==typeof window?console.log("redux-saga "+n+": "+t+"\n"+(e&&e.stack||e)):console[n](t,e)}function l(n,t){return function(){return n.apply(void 0,arguments)}}function s(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments[1],e=Array(n),r=0,o=0,u=0,a=function(t){e[o]=t,o=(o+1)%n,r++},i=function(){if(0!=r){var t=e[u];return e[u]=null,r--,u=(u+1)%n,t}},c=function(){for(var n=[];r;)n.push(i());return n};return{isEmpty:function(){return 0==r},put:function(i){if(n>r)a(i);else{var f=void 0;switch(t){case jn:throw Error(_n);case Sn:e[o]=i,o=(o+1)%n,u=o;break;case Tn:f=2*n,e=c(),r=e.length,o=e.length,u=0,e.length=f,n=f,a(i)}}},take:i,flush:c}}function d(n){try{g(),n()}finally{h()}}function v(n){Rn.push(n),Ln||(g(),p())}function g(){Ln++}function h(){Ln--}function p(){h();for(var n=void 0;!Ln&&void 0!==(n=Rn.shift());)d(n)}function y(){function n(n){return e.push(n),function(){return r(e,n)}}function t(n){for(var t=e.slice(),r=0,o=t.length;o>r;r++)t[r](n)}var e=[];return{subscribe:n,emit:t}}function m(){function n(){if(c&&f.length)throw Cn("Cannot have a closed channel with pending takers");if(f.length&&!i.isEmpty())throw Cn("Cannot have pending takers with non empty buffer")}function e(e){if(n(),t(e,hn.notUndef,In),!c){if(!f.length)return i.put(e);for(var r=0;f.length>r;r++){var o=f[r];if(!o[an]||o[an](e))return f.splice(r,1),o(e)}}}function o(e){n(),t(e,hn.func,"channel.take's callback must be a function"),c&&i.isEmpty()?e(qn):i.isEmpty()?(f.push(e),e.cancel=function(){return r(f,e)}):e(i.take())}function u(e){if(n(),t(e,hn.func,"channel.flush' callback must be a function"),c&&i.isEmpty())return void e(qn);e(i.flush())}function a(){if(n(),!c&&(c=!0,f.length)){var t=f;f=[];for(var e=0,r=t.length;r>e;e++)t[e](qn)}}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Nn.fixed(),c=!1,f=[];return t(i,hn.buffer,Mn),{take:o,put:e,flush:u,close:a,get __takers__(){return f},get __closed__(){return c}}}function b(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Nn.none(),r=arguments[2];arguments.length>2&&t(r,hn.func,"Invalid match function passed to eventChannel");var o=m(e),u=function(){o.__closed__||(a&&a(),o.close())},a=n(function(n){if(Un(n))return void u();r&&!r(n)||o.put(n)});if(o.__closed__&&a(),!hn.func(a))throw Error("in eventChannel: subscribe should return a function to unsubscribe");return{take:o.take,flush:o.flush,close:u}}function E(n){var e=b(function(t){return n(function(n){if(n[fn])return void t(n);v(function(){return t(n)})})});return tn({},e,{take:function(n,r){arguments.length>1&&(t(r,hn.func,"channel.take's matcher argument must be a function"),n[an]=r),e.take(n)}})}function k(n){return hn.channel(n)?"channel":Array.isArray(n)?n.map(function(n){return n+""})+"":n+""}function C(n,t){function e(t,e){if(u===Dn)return Pn;if(e)throw u=Dn,e;o&&o(t);var r=n[u](),a=r[0],i=r[1],c=r[2];return u=a,o=c,u===Dn?Pn:i}var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"iterator",o=void 0,u=t;return c(e,function(n){return e(null,n)},r,!0)}function A(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];var u={done:!1,value:_(n)},a=function(n){return{done:!1,value:q.apply(void 0,[t].concat(r,[n]))}},i=void 0,c=function(n){return i=n};return C({q1:function(){return["q2",u,c]},q2:function(){return i===qn?[Dn]:["q1",a(i)]}},"q1","takeEvery("+k(n)+", "+t.name+")")}function x(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];var u={done:!1,value:_(n)},a=function(n){return{done:!1,value:q.apply(void 0,[t].concat(r,[n]))}},i=function(n){return{done:!1,value:I(n)}},c=void 0,f=void 0,l=function(n){return c=n},s=function(n){return f=n};return C({q1:function(){return["q2",u,s]},q2:function(){return f===qn?[Dn]:c?["q3",i(c)]:["q1",a(f),l]},q3:function(){return["q1",a(f),l]}},"q1","takeLatest("+k(n)+", "+t.name+")")}function w(n,t,e){for(var r=arguments.length,o=Array(r>3?r-3:0),u=3;r>u;u++)o[u-3]=arguments[u];var i=void 0,c=void 0,f={done:!1,value:D(t,Nn.sliding(1))},l=function(){return{done:!1,value:_(c)}},s=function(n){return{done:!1,value:q.apply(void 0,[e].concat(o,[n]))}},d={done:!1,value:N(a,n)},v=function(n){return i=n},g=function(n){return c=n};return C({q1:function(){return["q2",f,g]},q2:function(){return["q3",l(),v]},q3:function(){return i===qn?[Dn]:["q4",s(i)]},q4:function(){return["q2",d]}},"q1","throttle("+k(t)+", "+e.name+")")}function _(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*";if(arguments.length&&t(arguments[0],hn.notUndef,"take(patternOrChannel): patternOrChannel is undefined"),hn.pattern(n))return it(Bn,{pattern:n});if(hn.channel(n))return it(Bn,{channel:n});throw Error("take(patternOrChannel): argument "+n+" is not valid channel or a valid pattern")}function j(n,e){return arguments.length>1?(t(n,hn.notUndef,"put(channel, action): argument channel is undefined"),t(n,hn.channel,"put(channel, action): argument "+n+" is not a valid channel"),t(e,hn.notUndef,"put(channel, action): argument action is undefined")):(t(n,hn.notUndef,"put(action): argument action is undefined"),e=n,n=null),it(Xn,{channel:n,action:e})}function S(n){return it(Jn,n)}function T(n){return it(Qn,n)}function O(n,e,r){t(e,hn.notUndef,n+": argument fn is undefined");var o=null;if(hn.array(e)){var u=e;o=u[0],e=u[1]}else if(e.fn){var a=e;o=a.context,e=a.fn}return o&&hn.string(e)&&hn.func(o[e])&&(e=o[e]),t(e,hn.func,n+": argument "+e+" is not a function"),{context:o,fn:e,args:r}}function N(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return it(Vn,O("call",n,e))}function R(n,t){return it(Vn,O("apply",{context:n,fn:t},arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]))}function L(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return it(Wn,O("cps",n,e))}function q(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return it(Yn,O("fork",n,e))}function U(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];var o=q.apply(void 0,[n].concat(e));return o[Yn].detached=!0,o}function M(){for(var n=arguments.length,e=Array(n),r=0;n>r;r++)e[r]=arguments[r];if(e.length>1)return S(e.map(function(n){return M(n)}));var o=e[0];return t(o,hn.notUndef,"join(task): argument task is undefined"),t(o,hn.task,"join(task): argument "+o+" is not a valid Task object "+at),it(Zn,o)}function I(){for(var n=arguments.length,e=Array(n),r=0;n>r;r++)e[r]=arguments[r];if(e.length>1)return S(e.map(function(n){return I(n)}));var o=e[0];return 1===e.length&&(t(o,hn.notUndef,"cancel(task): argument task is undefined"),t(o,hn.task,"cancel(task): argument "+o+" is not a valid Task object "+at)),it($n,o||ln)}function P(n){for(var e=arguments.length,r=Array(e>1?e-1:0),o=1;e>o;o++)r[o-1]=arguments[o];return 0===arguments.length?n=vn:(t(n,hn.notUndef,"select(selector,[...]): argument selector is undefined"),t(n,hn.func,"select(selector,[...]): argument "+n+" is not a function")),it(nt,{selector:n,args:r})}function D(n,e){return t(n,hn.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&(t(e,hn.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),t(e,hn.buffer,"actionChannel(pattern, buffer): argument "+e+" is not a valid buffer")),it(tt,{pattern:n,buffer:e})}function H(){return it(et,{})}function G(n){return t(n,hn.channel,"flush(channel): argument "+n+" is not valid channel"),it(rt,n)}function F(n){return t(n,hn.string,"getContext(prop): argument "+n+" is not a string"),it(ot,n)}function K(n){return t(n,hn.object,An(null,n)),it(ut,n)}function z(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return q.apply(void 0,[A,n,t].concat(r))}function B(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return q.apply(void 0,[x,n,t].concat(r))}function X(n,t,e){for(var r=arguments.length,o=Array(r>3?r-3:0),u=3;r>u;u++)o[u-3]=arguments[u];return q.apply(void 0,[w,n,t,e].concat(o))}function J(n){return("*"===n?gt.wildcard:hn.array(n)?gt.array:hn.stringableFunc(n)?gt.default:hn.func(n)?gt.predicate:gt.default)(n)}function Q(n,t,e){function o(n){a(),e(n,!0)}function u(n){i.push(n),n.cont=function(u,a){f||(r(i,n),n.cont=dn,a?o(u):(n===t&&(c=u),i.length||(f=!0,e(c))))}}function a(){f||(f=!0,i.forEach(function(n){n.cont=dn,n.cancel()}),i=[])}var i=[],c=void 0,f=!1;return u(t),{addTask:u,cancelAll:a,abort:o,getTasks:function(){return i},taskNames:function(){return i.map(function(n){return n.name})}}}function V(n){var t=n.context,e=n.fn,r=n.args;if(hn.iterator(e))return e;var o=void 0,u=void 0;try{o=e.apply(t,r)}catch(n){u=n}return hn.iterator(o)?o:c(u?function(){throw u}:function(){var n=void 0,t={done:!1,value:o},e=function(n){return{done:!0,value:n}};return function(r){return n?e(r):(n=!0,t)}}())}function W(n){function e(){$.isRunning&&!$.isCancelled&&($.isCancelled=!0,a(vt))}function u(){n._isRunning&&!n._isCancelled&&(n._isCancelled=!0,en.cancelAll(),i(vt))}function a(t,e){if(!$.isRunning)throw Error("Trying to resume an already finished generator");try{var r=void 0;e?r=n.throw(t):t===vt?($.isCancelled=!0,a.cancel(),r=hn.func(n.return)?n.return(vt):{done:!0,value:vt}):r=t===dt?hn.func(n.return)?n.return():{done:!0}:n.next(t),r.done?($.isMainRunning=!1,$.cont&&$.cont(r.value)):c(r.value,P,"",a)}catch(n){$.isCancelled&&B("error","uncaught at "+D,n.message),$.isMainRunning=!1,$.cont(n,!0)}}function i(t,e){n._isRunning=!1,X.close(),e?(t instanceof Error&&(t.sagaStack="at "+D+" \n "+(t.sagaStack||t.stack)),Z.cont||(B("error","uncaught",t.sagaStack||t.stack),t instanceof Error&&z&&z(t)),n._error=t,n._isAborted=!0,n._deferredEnd&&n._deferredEnd.reject(t)):(n._result=t,n._deferredEnd&&n._deferredEnd.resolve(t)),Z.cont&&Z.cont(t,e),Z.joiners.forEach(function(n){return n.cb(t,e)}),Z.joiners=null}function c(n,t){function e(n,t){a||(a=!0,o.cancel=dn,F&&(t?F.effectRejected(u,n):F.effectResolved(u,n)),o(n,t))}var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments[3],u=mn();F&&F.effectTriggered({effectId:u,parentEffectId:t,label:r,effect:n});var a=void 0;e.cancel=dn,o.cancel=function(){if(!a){a=!0;try{e.cancel()}catch(n){B("error","uncaught at "+D,n.message)}e.cancel=dn,F&&F.effectCancelled(u)}};var i=void 0;return hn.promise(n)?s(n,e):hn.helper(n)?C(ht(n),u,e):hn.iterator(n)?d(n,u,D,e):hn.array(n)?G(n,u,e):(i=lt.take(n))?h(i,e):(i=lt.put(n))?y(i,e):(i=lt.all(n))?w(i,u,e):(i=lt.race(n))?_(i,u,e):(i=lt.call(n))?m(i,u,e):(i=lt.cps(n))?k(i,e):(i=lt.fork(n))?C(i,u,e):(i=lt.join(n))?A(i,e):(i=lt.cancel(n))?x(i,e):(i=lt.select(n))?j(i,e):(i=lt.actionChannel(n))?S(i,e):(i=lt.flush(n))?O(i,e):(i=lt.cancelled(n))?T(i,e):(i=lt.getContext(n))?N(i,e):(i=lt.setContext(n))?R(i,e):e(n)}function s(n,t){var e=n[cn];hn.func(e)?t.cancel=e:hn.func(n.abort)&&(t.cancel=function(){return n.abort()}),n.then(t,function(n){return t(n,!0)})}function d(n,t,e,r){W(n,L,q,U,Y,I,t,e,r)}function h(n,t){var e=n.channel,r=n.pattern,o=n.maybe;e=e||X;var u=function(n){return n instanceof Error?t(n,!0):t(Un(n)&&!o?dt:n)};try{e.take(u,J(r))}catch(n){return t(n,!0)}t.cancel=u.cancel}function y(n,t){var e=n.channel,r=n.action,o=n.resolve;v(function(){var n=void 0;try{n=(e?e.put:q)(r)}catch(n){if(e||o)return t(n,!0);B("error","uncaught at "+D,n.stack||n.message||n)}if(!o||!hn.promise(n))return t(n);s(n,t)})}function m(n,t,e){var r=n.context,o=n.fn,u=n.args,a=void 0;try{a=o.apply(r,u)}catch(n){return e(n,!0)}return hn.promise(a)?s(a,e):hn.iterator(a)?d(a,t,o.name,e):e(a)}function k(n,t){var e=n.context,r=n.fn,o=n.args;try{var u=function(n,e){return hn.undef(n)?t(e):t(n,!0)};r.apply(e,o.concat(u)),u.cancel&&(t.cancel=function(){return u.cancel()})}catch(n){return t(n,!0)}}function C(n,t,e){var r=n.context,o=n.fn,u=n.args,a=n.detached,i=V({context:r,fn:o,args:u});try{g();var c=W(i,L,q,U,Y,I,t,o.name,a?null:dn);a?e(c):i._isRunning?(en.addTask(c),e(c)):i._error?en.abort(i._error):e(c)}finally{p()}}function A(n,t){if(n.isRunning()){var e={task:Z,cb:t};t.cancel=function(){return r(n.joiners,e)},n.joiners.push(e)}else n.isAborted()?t(n.error(),!0):t(n.result())}function x(n,t){n===ln&&(n=Z),n.isRunning()&&n.cancel(),t()}function w(n,t,e){function r(){u===o.length&&(a=!0,e(hn.array(n)?yn.from(tn({},i,{length:o.length})):i))}var o=Object.keys(n);if(!o.length)return e(hn.array(n)?[]:{});var u=0,a=void 0,i={},f={};o.forEach(function(n){var t=function(t,o){a||(o||Un(t)||t===dt||t===vt?(e.cancel(),e(t,o)):(i[n]=t,u++,r()))};t.cancel=dn,f[n]=t}),e.cancel=function(){a||(a=!0,o.forEach(function(n){return f[n].cancel()}))},o.forEach(function(e){return c(n[e],t,e,f[e])})}function _(n,t,e){var r=void 0,o=Object.keys(n),u={};o.forEach(function(n){var t=function(t,o){if(!r)if(o)e.cancel(),e(t,!0);else if(!Un(t)&&t!==dt&&t!==vt){var u;e.cancel(),r=!0,e((u={},u[n]=t,u))}};t.cancel=dn,u[n]=t}),e.cancel=function(){r||(r=!0,o.forEach(function(n){return u[n].cancel()}))},o.forEach(function(e){r||c(n[e],t,e,u[e])})}function j(n,t){var e=n.selector,r=n.args;try{var o=e.apply(void 0,[U()].concat(r));t(o)}catch(n){t(n,!0)}}function S(n,t){var e=n.pattern,r=n.buffer,o=J(e);o.pattern=e,t(b(L,r||Nn.fixed(),o))}function T(n,t){t(!!$.isCancelled)}function O(n,t){n.flush(t)}function N(n,t){t(Y[n])}function R(n,t){pn.assign(Y,n),t()}var L=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return dn},q=arguments.length>2&&void 0!==arguments[2]?arguments[2]:dn,U=arguments.length>3&&void 0!==arguments[3]?arguments[3]:dn,M=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},I=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},P=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,D=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"anonymous",H=arguments[8];t(n,hn.iterator,st);var G=l(w,kn("[...effects]","all([...effects])")),F=I.sagaMonitor,K=I.logger,z=I.onError,B=K||f,X=E(L),Y=Object.create(M);a.cancel=dn;var Z=function(n,e,r,a){var i,c,f;return r._deferredEnd=null,c={},c[on]=!0,c.id=n,c.name=e,i="done",f={},f[i]=f[i]||{},f[i].get=function(){if(r._deferredEnd)return r._deferredEnd.promise;var n=o();return r._deferredEnd=n,r._isRunning||(r._error?n.reject(r._error):n.resolve(r._result)),n.promise},c.cont=a,c.joiners=[],c.cancel=u,c.isRunning=function(){return r._isRunning},c.isCancelled=function(){return r._isCancelled},c.isAborted=function(){return r._isAborted},c.result=function(){return r._result},c.error=function(){return r._error},c.setContext=function(n){t(n,hn.object,An("task",n)),pn.assign(Y,n)},nn(c,f),c}(P,D,n,H),$={name:D,cancel:e,isRunning:!0},en=Q(D,$,i);return H&&(H.cancel=u),n._isRunning=!0,a(),Z}function Y(n,e){for(var r=arguments.length,o=Array(r>2?r-2:0),u=2;r>u;u++)o[u-2]=arguments[u];var a=void 0;hn.iterator(n)?(a=n,n=e):(t(e,hn.func,pt),a=e.apply(void 0,o),t(a,hn.iterator,pt));var i=n,c=i.subscribe,f=i.dispatch,l=i.getState,s=i.context,d=i.sagaMonitor,v=i.logger,g=i.onError,h=mn();d&&(d.effectTriggered=d.effectTriggered||dn,d.effectResolved=d.effectResolved||dn,d.effectRejected=d.effectRejected||dn,d.effectCancelled=d.effectCancelled||dn,d.actionDispatched=d.actionDispatched||dn,d.effectTriggered({effectId:h,root:!0,parentEffectId:0,effect:{root:!0,saga:e,args:o}}));var p=W(a,c,xn(f),l,s,{sagaMonitor:d,logger:v,onError:g},h,e.name);return d&&d.effectResolved(h,p),p}function Z(){function n(t){var e=t.getState,r=t.dispatch,f=y();return f.emit=(u.emitter||vn)(f.emit),n.run=Y.bind(null,{context:o,subscribe:f.subscribe,dispatch:r,getState:e,sagaMonitor:a,logger:i,onError:c}),function(n){return function(t){a&&a.actionDispatched&&a.actionDispatched(t);var e=n(t);return f.emit(t),e}}}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.context,o=void 0===r?{}:r,u=en(e,["context"]),a=u.sagaMonitor,i=u.logger,c=u.onError;if(hn.func(u))throw Error("Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead");if(i&&!hn.func(i))throw Error("`options.logger` passed to the Saga middleware is not a function!");if(c&&!hn.func(c))throw Error("`options.onError` passed to the Saga middleware is not a function!");if(u.emitter&&!hn.func(u.emitter))throw Error("`options.emitter` passed to the Saga middleware is not a function!");return n.run=function(){throw Error("Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware")},n.setContext=function(n){t(n,hn.object,An("sagaMiddleware",n)),pn.assign(o,n)},n}var $="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},nn=function(n,t){for(var e in t){var r=t[e];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,e,r)}return n},tn=Object.assign||function(n){for(var t=1;arguments.length>t;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},en=function(n,t){var e={};for(var r in n)0>t.indexOf(r)&&Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},rn=function(n){return"@@redux-saga/"+n},on=rn("TASK"),un=rn("HELPER"),an=rn("MATCH"),cn=rn("CANCEL_PROMISE"),fn=rn("SAGA_ACTION"),ln=rn("SELF_CANCELLATION"),sn=function(n){return function(){return n}}(!0),dn=function(){},vn=function(n){return n},gn=Object.prototype.hasOwnProperty,hn={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},string:function(n){return"string"==typeof n},array:Array.isArray,object:function(n){return n&&!hn.array(n)&&"object"===(void 0===n?"undefined":$(n))},promise:function(n){return n&&hn.func(n.then)},iterator:function(n){return n&&hn.func(n.next)&&hn.func(n.throw)},iterable:function(n){return n&&hn.func(Symbol)?hn.func(n[Symbol.iterator]):hn.array(n)},task:function(n){return n&&n[on]},observable:function(n){return n&&hn.func(n.subscribe)},buffer:function(n){return n&&hn.func(n.isEmpty)&&hn.func(n.take)&&hn.func(n.put)},pattern:function(n){return n&&(hn.string(n)||"symbol"===(void 0===n?"undefined":$(n))||hn.func(n)||hn.array(n))},channel:function(n){return n&&hn.func(n.take)&&hn.func(n.close)},helper:function(n){return n&&n[un]},stringableFunc:function(n){return hn.func(n)&&e(n,"toString")}},pn={assign:function(n,t){for(var r in t)e(t,r)&&(n[r]=t[r])}},yn={from:function(n){var t=Array(n.length);for(var r in n)e(n,r)&&(t[r]=n[r]);return t}},mn=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(){return++n}}(),bn=function(n){throw n},En=function(n){return{value:n,done:!0}},kn=function(n,t){return n+" has been deprecated in favor of "+t+", please update your code"},Cn=function(n){return 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")},An=function(n,t){return(n?n+".":"")+"setContext(props): argument "+t+" is not a plain object"},xn=function(n){return function(t){return n(Object.defineProperty(t,fn,{value:!0}))}},wn=function n(t){return function(){for(var e=arguments.length,r=Array(e),o=0;e>o;o++)r[o]=arguments[o];var u=[],a=t.apply(void 0,r);return{next:function(n){return u.push(n),a.next(n)},clone:function(){var e=n(t).apply(void 0,r);return u.forEach(function(n){return e.next(n)}),e},return:function(n){return a.return(n)},throw:function(n){return a.throw(n)}}}},_n="Channel's Buffer overflow!",jn=1,Sn=3,Tn=4,On={isEmpty:sn,put:dn,take:dn},Nn={none:function(){return On},fixed:function(n){return s(n,jn)},dropping:function(n){return s(n,2)},sliding:function(n){return s(n,Sn)},expanding:function(n){return s(n,Tn)}},Rn=[],Ln=0,qn={type:"@@redux-saga/CHANNEL_END"},Un=function(n){return n&&"@@redux-saga/CHANNEL_END"===n.type},Mn="invalid buffer passed to channel factory function",In="Saga was provided with an undefined action",Pn={done:!0,value:void 0},Dn={},Hn=function(n){return"import { "+n+" } from 'redux-saga' has been deprecated in favor of import { "+n+" } from 'redux-saga/effects'.\nThe latter will not work with yield*, as helper effects are wrapped automatically for you in fork effect.\nTherefore yield "+n+" will return task descriptor to your saga and execute next lines of code."},Gn=l(A,Hn("takeEvery")),Fn=l(x,Hn("takeLatest")),Kn=l(w,Hn("throttle")),zn=rn("IO"),Bn="TAKE",Xn="PUT",Jn="ALL",Qn="RACE",Vn="CALL",Wn="CPS",Yn="FORK",Zn="JOIN",$n="CANCEL",nt="SELECT",tt="ACTION_CHANNEL",et="CANCELLED",rt="FLUSH",ot="GET_CONTEXT",ut="SET_CONTEXT",at="\n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)",it=function(n,t){var e;return e={},e[zn]=!0,e[n]=t,e};_.maybe=function(){var n=_.apply(void 0,arguments);return n[Bn].maybe=!0,n};var ct=l(_.maybe,kn("takem","take.maybe"));j.resolve=function(){var n=j.apply(void 0,arguments);return n[Xn].resolve=!0,n},j.sync=l(j.resolve,kn("put.sync","put.resolve"));var ft=function(n){return function(t){return t&&t[zn]&&t[n]}},lt={take:ft(Bn),put:ft(Xn),all:ft(Jn),race:ft(Qn),call:ft(Vn),cps:ft(Wn),fork:ft(Yn),join:ft(Zn),cancel:ft($n),select:ft(nt),actionChannel:ft(tt),cancelled:ft(et),flush:ft(rt),getContext:ft(ot),setContext:ft(ut)},st="proc first argument (Saga function result) must be an iterator",dt={toString:function(){return"@@redux-saga/CHANNEL_END"}},vt={toString:function(){return"@@redux-saga/TASK_CANCEL"}},gt={wildcard:function(){return sn},default:function(n){return"symbol"===(void 0===n?"undefined":$(n))?function(t){return t.type===n}:function(t){return t.type===n+""}},array:function(n){return function(t){return n.some(function(n){return J(n)(t)})}},predicate:function(n){return function(t){return n(t)}}},ht=function(n){return{fn:n}},pt="runSaga(storeInterface, saga, ...args): saga argument must be a Generator function!",yt=Object.freeze({take:_,takem:ct,put:j,all:S,race:T,call:N,apply:R,cps:L,fork:q,spawn:U,join:M,cancel:I,select:P,actionChannel:D,cancelled:H,flush:G,getContext:F,setContext:K,takeEvery:z,takeLatest:B,throttle:X}),mt=Object.freeze({TASK:on,SAGA_ACTION:fn,noop:dn,is:hn,deferred:o,arrayOfDeffered:u,createMockTask:i,cloneableGenerator:wn,asEffect:lt,CHANNEL_END:dt});n.default=Z,n.effects=yt,n.utils=mt,n.runSaga=Y,n.END=qn,n.eventChannel=b,n.channel=m,n.buffers=Nn,n.takeEvery=Gn,n.takeLatest=Fn,n.throttle=Kn,n.delay=a,n.CANCEL=cn,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.ReduxSaga={})}(this,function(n){"use strict";function t(n,t,e){if(!t(n))throw c("error","uncaught at check",e),Error(e)}function e(n,t){return nn.notUndef(n)&&$.call(n,t)}function r(n,t){var e=n.indexOf(t);0>e||n.splice(e,1)}function o(){var n=H({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),t=new Promise(function(t,e){n.resolve=t,n.reject=e});return n.promise=t,n}function a(n){var t=1>=arguments.length||void 0===arguments[1]||arguments[1],e=void 0,r=new Promise(function(r){e=setTimeout(function(){return r(t)},n)});return r[X]=function(){return clearTimeout(e)},r}function u(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:on,e={name:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",next:n,throw:t,return:an};return arguments[3]&&(e[z]=!0),"undefined"!=typeof Symbol&&(e[Symbol.iterator]=function(){return e}),e}function c(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";"undefined"==typeof window?console.log("redux-saga "+n+": "+t+"\n"+(e&&e.stack||e)):console[n](t,e)}function i(n,t){return function(){return n.apply(void 0,arguments)}}function f(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments[1],e=Array(n),r=0,o=0,a=0,u=function(t){e[o]=t,o=(o+1)%n,r++},c=function(){if(0!=r){var t=e[a];return e[a]=null,r--,a=(a+1)%n,t}},i=function(){for(var n=[];r;)n.push(c());return n};return{isEmpty:function(){return 0==r},put:function(c){if(n>r)u(c);else{var f=void 0;switch(t){case dn:throw Error(sn);case vn:e[o]=c,a=o=(o+1)%n;break;case gn:f=2*n,e=i(),r=e.length,o=e.length,a=0,e.length=f,n=f,u(c)}}},take:c,flush:i}}function l(n){try{d(),n()}finally{v()}}function s(n){yn.push(n),mn||(d(),g())}function d(){mn++}function v(){mn--}function g(){v();for(var n=void 0;!mn&&void 0!==(n=yn.shift());)l(n)}function h(){var n=[];return{subscribe:function(t){return n.push(t),function(){return r(n,t)}},emit:function(t){for(var e=n.slice(),r=0,o=e.length;o>r;r++)e[r](t)}}}function p(){function n(){if(o&&a.length)throw cn("Cannot have a closed channel with pending takers");if(a.length&&!e.isEmpty())throw cn("Cannot have pending takers with non empty buffer")}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:pn.fixed(),o=!1,a=[];return t(e,nn.buffer,kn),{take:function(u){n(),t(u,nn.func,"channel.take's callback must be a function"),o&&e.isEmpty()?u(bn):e.isEmpty()?(a.push(u),u.cancel=function(){return r(a,u)}):u(e.take())},put:function(r){if(n(),t(r,nn.notUndef,Cn),!o){if(!a.length)return e.put(r);for(var u=0;a.length>u;u++){var c=a[u];if(!c[B]||c[B](r))return a.splice(u,1),c(r)}}},flush:function(r){n(),t(r,nn.func,"channel.flush' callback must be a function"),r(o&&e.isEmpty()?bn:e.flush())},close:function(){if(n(),!o&&(o=!0,a.length)){var t=a;a=[];for(var e=0,r=t.length;r>e;e++)t[e](bn)}},get __takers__(){return a},get __closed__(){return o}}}function y(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pn.none(),r=arguments[2];arguments.length>2&&t(r,nn.func,"Invalid match function passed to eventChannel");var o=p(e),a=function(){o.__closed__||(u&&u(),o.close())},u=n(function(n){En(n)?a():r&&!r(n)||o.put(n)});if(o.__closed__&&u(),!nn.func(u))throw Error("in eventChannel: subscribe should return a function to unsubscribe");return{take:o.take,flush:o.flush,close:a}}function m(n){var e=y(function(t){return n(function(n){n[J]?t(n):s(function(){return t(n)})})});return H({},e,{take:function(n,r){arguments.length>1&&(t(r,nn.func,"channel.take's matcher argument must be a function"),n[B]=r),e.take(n)}})}function b(n){return nn.channel(n)?"channel":Array.isArray(n)?n.map(function(n){return n+""})+"":n+""}function E(n,t){function e(t,e){if(o===An)return _n;if(e)throw o=An,e;r&&r(t);var a=n[o](),u=a[0],c=a[1];return o=u,r=a[2],o===An?_n:c}var r=void 0,o=t;return u(e,function(n){return e(null,n)},arguments.length>2&&void 0!==arguments[2]?arguments[2]:"iterator",!0)}function k(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];var a={done:!1,value:A(n)},u=function(n){return{done:!1,value:T.apply(void 0,[t].concat(r,[n]))}},c=void 0,i=function(n){return c=n};return E({q1:function(){return["q2",a,i]},q2:function(){return c===bn?[An]:["q1",u(c)]}},"q1","takeEvery("+b(n)+", "+t.name+")")}function C(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];var a={done:!1,value:A(n)},u=function(n){return{done:!1,value:T.apply(void 0,[t].concat(r,[n]))}},c=function(n){return{done:!1,value:N(n)}},i=void 0,f=void 0,l=function(n){return i=n},s=function(n){return f=n};return E({q1:function(){return["q2",a,s]},q2:function(){return f===bn?[An]:i?["q3",c(i)]:["q1",u(f),l]},q3:function(){return["q1",u(f),l]}},"q1","takeLatest("+b(n)+", "+t.name+")")}function _(n,t,e){for(var r=arguments.length,o=Array(r>3?r-3:0),u=3;r>u;u++)o[u-3]=arguments[u];var c=void 0,i=void 0,f={done:!1,value:R(t,pn.sliding(1))},l=function(){return{done:!1,value:A(i)}},s=function(n){return{done:!1,value:T.apply(void 0,[e].concat(o,[n]))}},d={done:!1,value:j(a,n)},v=function(n){return c=n},g=function(n){return i=n};return E({q1:function(){return["q2",f,g]},q2:function(){return["q3",l(),v]},q3:function(){return c===bn?[An]:["q4",s(c)]},q4:function(){return["q2",d]}},"q1","throttle("+b(t)+", "+e.name+")")}function A(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*";if(arguments.length&&t(arguments[0],nn.notUndef,"take(patternOrChannel): patternOrChannel is undefined"),nn.pattern(n))return Xn(On,{pattern:n});if(nn.channel(n))return Xn(On,{channel:n});throw Error("take(patternOrChannel): argument "+n+" is not valid channel or a valid pattern")}function x(n,e){return arguments.length>1?(t(n,nn.notUndef,"put(channel, action): argument channel is undefined"),t(n,nn.channel,"put(channel, action): argument "+n+" is not a valid channel"),t(e,nn.notUndef,"put(channel, action): argument action is undefined")):(t(n,nn.notUndef,"put(action): argument action is undefined"),e=n,n=null),Xn(Nn,{channel:n,action:e})}function w(n){return Xn(Rn,n)}function S(n,e,r){t(e,nn.notUndef,n+": argument fn is undefined");var o=null;if(nn.array(e)){var a=e;o=a[0],e=a[1]}else if(e.fn){var u=e;o=u.context,e=u.fn}return o&&nn.string(e)&&nn.func(o[e])&&(e=o[e]),t(e,nn.func,n+": argument "+e+" is not a function"),{context:o,fn:e,args:r}}function j(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Xn(qn,S("call",n,e))}function T(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Xn(Mn,S("fork",n,e))}function O(){for(var n=arguments.length,e=Array(n),r=0;n>r;r++)e[r]=arguments[r];if(e.length>1)return w(e.map(function(n){return O(n)}));var o=e[0];return t(o,nn.notUndef,"join(task): argument task is undefined"),t(o,nn.task,"join(task): argument "+o+" is not a valid Task object "+Bn),Xn(In,o)}function N(){for(var n=arguments.length,e=Array(n),r=0;n>r;r++)e[r]=arguments[r];if(e.length>1)return w(e.map(function(n){return N(n)}));var o=e[0];return 1===e.length&&(t(o,nn.notUndef,"cancel(task): argument task is undefined"),t(o,nn.task,"cancel(task): argument "+o+" is not a valid Task object "+Bn)),Xn(Pn,o||Q)}function R(n,e){return t(n,nn.notUndef,"actionChannel(pattern,...): argument pattern is undefined"),arguments.length>1&&(t(e,nn.notUndef,"actionChannel(pattern, buffer): argument buffer is undefined"),t(e,nn.buffer,"actionChannel(pattern, buffer): argument "+e+" is not a valid buffer")),Xn(Hn,{pattern:n,buffer:e})}function L(n){return("*"===n?nt.wildcard:nn.array(n)?nt.array:nn.stringableFunc(n)?nt.default:nn.func(n)?nt.predicate:nt.default)(n)}function q(n,t,e){function o(n){u(),e(n,!0)}function a(n){c.push(n),n.cont=function(a,u){f||(r(c,n),n.cont=Y,u?o(a):(n===t&&(i=a),c.length||(f=!0,e(i))))}}function u(){f||(f=!0,c.forEach(function(n){n.cont=Y,n.cancel()}),c=[])}var c=[],i=void 0,f=!1;return a(t),{addTask:a,cancelAll:u,abort:o,getTasks:function(){return c},taskNames:function(){return c.map(function(n){return n.name})}}}function U(n){var t=n.context,e=n.fn,r=n.args;if(nn.iterator(e))return e;var o=void 0,a=void 0;try{o=e.apply(t,r)}catch(n){a=n}return nn.iterator(o)?o:u(a?function(){throw a}:function(){var n=void 0,t={done:!1,value:o},e=function(n){return{done:!0,value:n}};return function(r){return n?e(r):(n=!0,t)}}())}function M(n){function e(){n._isRunning&&!n._isCancelled&&(n._isCancelled=!0,vn.cancelAll(),u($n))}function a(t,e){if(!dn.isRunning)throw Error("Trying to resume an already finished generator");try{var r=void 0;e?r=n.throw(t):t===$n?(dn.isCancelled=!0,a.cancel(),r=nn.func(n.return)?n.return($n):{done:!0,value:$n}):r=t===Zn?nn.func(n.return)?n.return():{done:!0}:n.next(t),r.done?(dn.isMainRunning=!1,dn.cont&&dn.cont(r.value)):f(r.value,z,"",a)}catch(n){dn.isCancelled&&an(n),dn.isMainRunning=!1,dn.cont(n,!0)}}function u(t,e){n._isRunning=!1,cn.close(),e?(t instanceof Error&&Object.defineProperty(t,"sagaStack",{value:"at "+B+" \n "+(t.sagaStack||t.stack),configurable:!0}),sn.cont||(t instanceof Error&&$?$(t):an(t)),n._error=t,n._isAborted=!0,n._deferredEnd&&n._deferredEnd.reject(t)):(n._result=t,n._deferredEnd&&n._deferredEnd.resolve(t)),sn.cont&&sn.cont(t,e),sn.joiners.forEach(function(n){return n.cb(t,e)}),sn.joiners=null}function f(n,t){function e(n,t){u||(u=!0,o.cancel=Y,W&&(t?W.effectRejected(a,n):W.effectResolved(a,n)),o(n,t))}var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments[3],a=rn();W&&W.effectTriggered({effectId:a,parentEffectId:t,label:r,effect:n});var u=void 0;e.cancel=Y,o.cancel=function(){if(!u){u=!0;try{e.cancel()}catch(n){an(n)}e.cancel=Y,W&&W.effectCancelled(a)}};var c=void 0;return nn.promise(n)?l(n,e):nn.helper(n)?k(tt(n),a,e):nn.iterator(n)?v(n,a,B,e):nn.array(n)?V(n,a,e):(c=Wn.take(n))?h(c,e):(c=Wn.put(n))?p(c,e):(c=Wn.all(n))?A(c,a,e):(c=Wn.race(n))?x(c,a,e):(c=Wn.call(n))?b(c,a,e):(c=Wn.cps(n))?E(c,e):(c=Wn.fork(n))?k(c,a,e):(c=Wn.join(n))?C(c,e):(c=Wn.cancel(n))?_(c,e):(c=Wn.select(n))?w(c,e):(c=Wn.actionChannel(n))?S(c,e):(c=Wn.flush(n))?T(c,e):(c=Wn.cancelled(n))?j(c,e):(c=Wn.getContext(n))?O(c,e):(c=Wn.setContext(n))?N(c,e):e(n)}function l(n,t){var e=n[X];nn.func(e)?t.cancel=e:nn.func(n.abort)&&(t.cancel=function(){return n.abort()}),n.then(t,function(n){return t(n,!0)})}function v(n,t,e,r){M(n,R,I,P,ln,F,t,e,r)}function h(n,t){var e=n.channel,r=n.pattern,o=n.maybe;e=e||cn;var a=function(n){return n instanceof Error?t(n,!0):t(En(n)&&!o?Zn:n)};try{e.take(a,L(r))}catch(n){return t(n,!0)}t.cancel=a.cancel}function p(n,t){var e=n.channel,r=n.action,o=n.resolve;s(function(){var n=void 0;try{n=(e?e.put:I)(r)}catch(n){if(e||o)return t(n,!0);an(n)}if(!o||!nn.promise(n))return t(n);l(n,t)})}function b(n,t,e){var r=n.context,o=n.fn,a=n.args,u=void 0;try{u=o.apply(r,a)}catch(n){return e(n,!0)}return nn.promise(u)?l(u,e):nn.iterator(u)?v(u,t,o.name,e):e(u)}function E(n,t){var e=n.context,r=n.fn,o=n.args;try{var a=function(n,e){return nn.undef(n)?t(e):t(n,!0)};r.apply(e,o.concat(a)),a.cancel&&(t.cancel=function(){return a.cancel()})}catch(n){return t(n,!0)}}function k(n,t,e){var r=n.context,o=n.fn,a=n.args,u=n.detached,c=U({context:r,fn:o,args:a});try{d();var i=M(c,R,I,P,ln,F,t,o.name,u?null:Y);u?e(i):c._isRunning?(vn.addTask(i),e(i)):c._error?vn.abort(c._error):e(i)}finally{g()}}function C(n,t){if(n.isRunning()){var e={task:sn,cb:t};t.cancel=function(){return r(n.joiners,e)},n.joiners.push(e)}else n.isAborted()?t(n.error(),!0):t(n.result())}function _(n,t){n===Q&&(n=sn),n.isRunning()&&n.cancel(),t()}function A(n,t,e){function r(){a===o.length&&(u=!0,e(nn.array(n)?en.from(H({},c,{length:o.length})):c))}var o=Object.keys(n);if(!o.length)return e(nn.array(n)?[]:{});var a=0,u=void 0,c={},i={};o.forEach(function(n){var t=function(t,o){u||(o||En(t)||t===Zn||t===$n?(e.cancel(),e(t,o)):(c[n]=t,a++,r()))};t.cancel=Y,i[n]=t}),e.cancel=function(){u||(u=!0,o.forEach(function(n){return i[n].cancel()}))},o.forEach(function(e){return f(n[e],t,e,i[e])})}function x(n,t,e){var r=void 0,o=Object.keys(n),a={};o.forEach(function(t){var u=function(a,u){if(!r)if(u)e.cancel(),e(a,!0);else if(!En(a)&&a!==Zn&&a!==$n){var c;e.cancel(),r=!0;var i=(c={},c[t]=a,c);e(nn.array(n)?[].slice.call(H({},i,{length:o.length})):i)}};u.cancel=Y,a[t]=u}),e.cancel=function(){r||(r=!0,o.forEach(function(n){return a[n].cancel()}))},o.forEach(function(e){r||f(n[e],t,e,a[e])})}function w(n,t){var e=n.selector,r=n.args;try{var o=e.apply(void 0,[P()].concat(r));t(o)}catch(n){t(n,!0)}}function S(n,t){var e=n.pattern,r=n.buffer,o=L(e);o.pattern=e,t(y(R,r||pn.fixed(),o))}function j(n,t){t(!!dn.isCancelled)}function T(n,t){n.flush(t)}function O(n,t){t(ln[n])}function N(n,t){tn.assign(ln,n),t()}var R=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return Y},I=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Y,P=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Y,G=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},F=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},z=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,B=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"anonymous",J=arguments[8];t(n,nn.iterator,Yn);var V=i(A,un("[...effects]","all([...effects])")),W=F.sagaMonitor,Z=F.logger,$=F.onError,on=Z||c,an=function(n){var t=n.sagaStack;!t&&n.stack&&(t=-1!==n.stack.split("\n")[0].indexOf(n.message)?n.stack:"Error: "+n.message+"\n"+n.stack),on("error","uncaught at "+B,t||n.message||n)},cn=m(R),ln=Object.create(G);a.cancel=Y;var sn=function(n,r,a,u){var c,i;return a._deferredEnd=null,c={},c[K]=!0,c.id=n,c.name=r,i={},i.done=i.done||{},i.done.get=function(){if(a._deferredEnd)return a._deferredEnd.promise;var n=o();return a._deferredEnd=n,a._isRunning||(a._error?n.reject(a._error):n.resolve(a._result)),n.promise},c.cont=u,c.joiners=[],c.cancel=e,c.isRunning=function(){return a._isRunning},c.isCancelled=function(){return a._isCancelled},c.isAborted=function(){return a._isAborted},c.result=function(){return a._result},c.error=function(){return a._error},c.setContext=function(n){t(n,nn.object,fn("task",n)),tn.assign(ln,n)},D(c,i),c}(z,B,n,J),dn={name:B,cancel:function(){dn.isRunning&&!dn.isCancelled&&(dn.isCancelled=!0,a($n))},isRunning:!0},vn=q(B,dn,u);return J&&(J.cancel=e),n._isRunning=!0,a(),sn}function I(n,e){for(var r=arguments.length,o=Array(r>2?r-2:0),a=2;r>a;a++)o[a-2]=arguments[a];var u=void 0;nn.iterator(n)?(u=n,n=e):(t(e,nn.func,et),t(u=e.apply(void 0,o),nn.iterator,et));var c=n,i=c.subscribe,f=c.dispatch,l=c.getState,s=c.context,d=c.sagaMonitor,v=c.logger,g=c.onError,h=rn();d&&(d.effectTriggered=d.effectTriggered||Y,d.effectResolved=d.effectResolved||Y,d.effectRejected=d.effectRejected||Y,d.effectCancelled=d.effectCancelled||Y,d.actionDispatched=d.actionDispatched||Y,d.effectTriggered({effectId:h,root:!0,parentEffectId:0,effect:{root:!0,saga:e,args:o}}));var p=M(u,i,ln(f),l,s,{sagaMonitor:d,logger:v,onError:g},h,e.name);return d&&d.effectResolved(h,p),p}var 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},D=function(n,t){for(var e in t){var r=t[e];r.configurable=r.enumerable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,e,r)}return n},H=Object.assign||function(n){for(var t=1;arguments.length>t;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},G=function(n,t){var e={};for(var r in n)0>t.indexOf(r)&&Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},F=function(n){return"@@redux-saga/"+n},K=F("TASK"),z=F("HELPER"),B=F("MATCH"),X=F("CANCEL_PROMISE"),J=F("SAGA_ACTION"),Q=F("SELF_CANCELLATION"),V=function(n){return function(){return n}},W=V(!0),Y=function(){},Z=function(n){return n},$=Object.prototype.hasOwnProperty,nn={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},string:function(n){return"string"==typeof n},array:Array.isArray,object:function(n){return n&&!nn.array(n)&&"object"===(void 0===n?"undefined":P(n))},promise:function(n){return n&&nn.func(n.then)},iterator:function(n){return n&&nn.func(n.next)&&nn.func(n.throw)},iterable:function(n){return n&&nn.func(Symbol)?nn.func(n[Symbol.iterator]):nn.array(n)},task:function(n){return n&&n[K]},observable:function(n){return n&&nn.func(n.subscribe)},buffer:function(n){return n&&nn.func(n.isEmpty)&&nn.func(n.take)&&nn.func(n.put)},pattern:function(n){return n&&(nn.string(n)||"symbol"===(void 0===n?"undefined":P(n))||nn.func(n)||nn.array(n))},channel:function(n){return n&&nn.func(n.take)&&nn.func(n.close)},helper:function(n){return n&&n[z]},stringableFunc:function(n){return nn.func(n)&&e(n,"toString")}},tn={assign:function(n,t){for(var r in t)e(t,r)&&(n[r]=t[r])}},en={from:function(n){var t=Array(n.length);for(var r in n)e(n,r)&&(t[r]=n[r]);return t}},rn=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(){return++n}}(),on=function(n){throw n},an=function(n){return{value:n,done:!0}},un=function(n,t){return n+" has been deprecated in favor of "+t+", please update your code"},cn=function(n){return 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")},fn=function(n,t){return(n?n+".":"")+"setContext(props): argument "+t+" is not a plain object"},ln=function(n){return function(t){return n(Object.defineProperty(t,J,{value:!0}))}},sn="Channel's Buffer overflow!",dn=1,vn=3,gn=4,hn={isEmpty:W,put:Y,take:Y},pn={none:function(){return hn},fixed:function(n){return f(n,dn)},dropping:function(n){return f(n,2)},sliding:function(n){return f(n,vn)},expanding:function(n){return f(n,gn)}},yn=[],mn=0,bn={type:"@@redux-saga/CHANNEL_END"},En=function(n){return n&&"@@redux-saga/CHANNEL_END"===n.type},kn="invalid buffer passed to channel factory function",Cn="Saga was provided with an undefined action",_n={done:!0,value:void 0},An={},xn=function(n){return"import { "+n+" } from 'redux-saga' has been deprecated in favor of import { "+n+" } from 'redux-saga/effects'.\nThe latter will not work with yield*, as helper effects are wrapped automatically for you in fork effect.\nTherefore yield "+n+" will return task descriptor to your saga and execute next lines of code."},wn=i(k,xn("takeEvery")),Sn=i(C,xn("takeLatest")),jn=i(_,xn("throttle")),Tn=F("IO"),On="TAKE",Nn="PUT",Rn="ALL",Ln="RACE",qn="CALL",Un="CPS",Mn="FORK",In="JOIN",Pn="CANCEL",Dn="SELECT",Hn="ACTION_CHANNEL",Gn="CANCELLED",Fn="FLUSH",Kn="GET_CONTEXT",zn="SET_CONTEXT",Bn="\n(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)",Xn=function(n,t){var e;return e={},e[Tn]=!0,e[n]=t,e},Jn=function(n){return t(Wn.fork(n),nn.object,"detach(eff): argument must be a fork effect"),n[Mn].detached=!0,n},Qn=i(A.maybe=function(){var n=A.apply(void 0,arguments);return n[On].maybe=!0,n},un("takem","take.maybe"));x.resolve=function(){var n=x.apply(void 0,arguments);return n[Nn].resolve=!0,n},x.sync=i(x.resolve,un("put.sync","put.resolve"));var Vn=function(n){return function(t){return t&&t[Tn]&&t[n]}},Wn={take:Vn(On),put:Vn(Nn),all:Vn(Rn),race:Vn(Ln),call:Vn(qn),cps:Vn(Un),fork:Vn(Mn),join:Vn(In),cancel:Vn(Pn),select:Vn(Dn),actionChannel:Vn(Hn),cancelled:Vn(Gn),flush:Vn(Fn),getContext:Vn(Kn),setContext:Vn(zn)},Yn="proc first argument (Saga function result) must be an iterator",Zn={toString:function(){return"@@redux-saga/CHANNEL_END"}},$n={toString:function(){return"@@redux-saga/TASK_CANCEL"}},nt={wildcard:function(){return W},default:function(n){return"symbol"===(void 0===n?"undefined":P(n))?function(t){return t.type===n}:function(t){return t.type===n+""}},array:function(n){return function(t){return n.some(function(n){return L(n)(t)})}},predicate:function(n){return function(t){return n(t)}}},tt=function(n){return{fn:n}},et="runSaga(storeInterface, saga, ...args): saga argument must be a Generator function!",rt=Object.freeze({take:A,takem:Qn,put:x,all:w,race:function(n){return Xn(Ln,n)},call:j,apply:function(n,t){return Xn(qn,S("apply",{context:n,fn:t},arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]))},cps:function(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Xn(Un,S("cps",n,e))},fork:T,spawn:function(n){for(var t=arguments.length,e=Array(t>1?t-1:0),r=1;t>r;r++)e[r-1]=arguments[r];return Jn(T.apply(void 0,[n].concat(e)))},join:O,cancel:N,select:function(n){for(var e=arguments.length,r=Array(e>1?e-1:0),o=1;e>o;o++)r[o-1]=arguments[o];return 0===arguments.length?n=Z:(t(n,nn.notUndef,"select(selector,[...]): argument selector is undefined"),t(n,nn.func,"select(selector,[...]): argument "+n+" is not a function")),Xn(Dn,{selector:n,args:r})},actionChannel:R,cancelled:function(){return Xn(Gn,{})},flush:function(n){return t(n,nn.channel,"flush(channel): argument "+n+" is not valid channel"),Xn(Fn,n)},getContext:function(n){return t(n,nn.string,"getContext(prop): argument "+n+" is not a string"),Xn(Kn,n)},setContext:function(n){return t(n,nn.object,fn(null,n)),Xn(zn,n)},takeEvery:function(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return T.apply(void 0,[k,n,t].concat(r))},takeLatest:function(n,t){for(var e=arguments.length,r=Array(e>2?e-2:0),o=2;e>o;o++)r[o-2]=arguments[o];return T.apply(void 0,[C,n,t].concat(r))},throttle:function(n,t,e){for(var r=arguments.length,o=Array(r>3?r-3:0),a=3;r>a;a++)o[a-3]=arguments[a];return T.apply(void 0,[_,n,t,e].concat(o))}}),ot=Object.freeze({TASK:K,SAGA_ACTION:J,noop:Y,is:nn,deferred:o,arrayOfDeffered:function(n){for(var t=[],e=0;n>e;e++)t.push(o());return t},createMockTask:function(){var n,t=!0,e=void 0,r=void 0;return n={},n[K]=!0,n.isRunning=function(){return t},n.result=function(){return e},n.error=function(){return r},n.setRunning=function(n){return t=n},n.setResult=function(n){return e=n},n.setError=function(n){return r=n},n},cloneableGenerator:function n(t){return function(){for(var e=arguments.length,r=Array(e),o=0;e>o;o++)r[o]=arguments[o];var a=[],u=t.apply(void 0,r);return{next:function(n){return a.push(n),u.next(n)},clone:function(){var e=n(t).apply(void 0,r);return a.forEach(function(n){return e.next(n)}),e},return:function(n){return u.return(n)},throw:function(n){return u.throw(n)}}}},asEffect:Wn,CHANNEL_END:Zn});n.default=function(){function n(t){var e=t.getState,r=t.dispatch,f=h();return f.emit=(a.emitter||Z)(f.emit),n.run=I.bind(null,{context:o,subscribe:f.subscribe,dispatch:r,getState:e,sagaMonitor:u,logger:c,onError:i}),function(n){return function(t){u&&u.actionDispatched&&u.actionDispatched(t);var e=n(t);return f.emit(t),e}}}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.context,o=void 0===r?{}:r,a=G(e,["context"]),u=a.sagaMonitor,c=a.logger,i=a.onError;if(nn.func(a))throw Error("Saga middleware no longer accept Generator functions. Use sagaMiddleware.run instead");if(c&&!nn.func(c))throw Error("`options.logger` passed to the Saga middleware is not a function!");if(i&&!nn.func(i))throw Error("`options.onError` passed to the Saga middleware is not a function!");if(a.emitter&&!nn.func(a.emitter))throw Error("`options.emitter` passed to the Saga middleware is not a function!");return n.run=function(){throw Error("Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware")},n.setContext=function(n){t(n,nn.object,fn("sagaMiddleware",n)),tn.assign(o,n)},n},n.effects=rt,n.utils=ot,n.runSaga=I,n.END=bn,n.eventChannel=y,n.channel=p,n.buffers=pn,n.takeEvery=wn,n.takeLatest=Sn,n.throttle=jn,n.delay=a,n.CANCEL=X,n.detach=Jn,Object.defineProperty(n,"__esModule",{value:!0})}); |
@@ -9,2 +9,3 @@ import middleware from './internal/middleware'; | ||
export { delay, CANCEL } from './internal/utils'; | ||
export { detach } from './internal/io'; | ||
@@ -11,0 +12,0 @@ import * as effects from './effects'; |
import { sym, is, ident, check, deprecate, updateIncentive, createSetContextWarning, SELF_CANCELLATION } from './utils'; | ||
import { takeEveryHelper, takeLatestHelper, throttleHelper } from './sagaHelpers'; | ||
var IO = sym('IO'); | ||
var IO = /*#__PURE__*/sym('IO'); | ||
var TAKE = 'TAKE'; | ||
@@ -29,2 +29,8 @@ var PUT = 'PUT'; | ||
export var detach = function detach(eff) { | ||
check(asEffect.fork(eff), is.object, 'detach(eff): argument must be a fork effect'); | ||
eff[FORK].detached = true; | ||
return eff; | ||
}; | ||
export function take() { | ||
@@ -72,3 +78,3 @@ var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*'; | ||
put.sync = deprecate(put.resolve, updateIncentive('put.sync', 'put.resolve')); | ||
put.sync = /*#__PURE__*/deprecate(put.resolve, /*#__PURE__*/updateIncentive('put.sync', 'put.resolve')); | ||
@@ -139,5 +145,3 @@ export function all(effects) { | ||
var eff = fork.apply(undefined, [fn].concat(args)); | ||
eff[FORK].detached = true; | ||
return eff; | ||
return detach(fork.apply(undefined, [fn].concat(args))); | ||
} | ||
@@ -255,17 +259,17 @@ | ||
export var asEffect = { | ||
take: createAsEffectType(TAKE), | ||
put: createAsEffectType(PUT), | ||
all: createAsEffectType(ALL), | ||
race: createAsEffectType(RACE), | ||
call: createAsEffectType(CALL), | ||
cps: createAsEffectType(CPS), | ||
fork: createAsEffectType(FORK), | ||
join: createAsEffectType(JOIN), | ||
cancel: createAsEffectType(CANCEL), | ||
select: createAsEffectType(SELECT), | ||
actionChannel: createAsEffectType(ACTION_CHANNEL), | ||
cancelled: createAsEffectType(CANCELLED), | ||
flush: createAsEffectType(FLUSH), | ||
getContext: createAsEffectType(GET_CONTEXT), | ||
setContext: createAsEffectType(SET_CONTEXT) | ||
take: /*#__PURE__*/createAsEffectType(TAKE), | ||
put: /*#__PURE__*/createAsEffectType(PUT), | ||
all: /*#__PURE__*/createAsEffectType(ALL), | ||
race: /*#__PURE__*/createAsEffectType(RACE), | ||
call: /*#__PURE__*/createAsEffectType(CALL), | ||
cps: /*#__PURE__*/createAsEffectType(CPS), | ||
fork: /*#__PURE__*/createAsEffectType(FORK), | ||
join: /*#__PURE__*/createAsEffectType(JOIN), | ||
cancel: /*#__PURE__*/createAsEffectType(CANCEL), | ||
select: /*#__PURE__*/createAsEffectType(SELECT), | ||
actionChannel: /*#__PURE__*/createAsEffectType(ACTION_CHANNEL), | ||
cancelled: /*#__PURE__*/createAsEffectType(CANCELLED), | ||
flush: /*#__PURE__*/createAsEffectType(FLUSH), | ||
getContext: /*#__PURE__*/createAsEffectType(GET_CONTEXT), | ||
setContext: /*#__PURE__*/createAsEffectType(SET_CONTEXT) | ||
}; |
@@ -203,2 +203,11 @@ 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 log = logger || _log; | ||
var logError = function logError(err) { | ||
var message = err.sagaStack; | ||
if (!message && err.stack) { | ||
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : 'Error: ' + err.message + '\n' + err.stack; | ||
} | ||
log('error', 'uncaught at ' + name, message || err.message || err); | ||
}; | ||
var stdChannel = _stdChannel(subscribe); | ||
@@ -317,3 +326,3 @@ var taskContext = Object.create(parentContext); | ||
if (mainTask.isCancelled) { | ||
log('error', 'uncaught at ' + name, error.message); | ||
logError(error); | ||
} | ||
@@ -329,5 +338,2 @@ mainTask.isMainRunning = false; | ||
if (!isErr) { | ||
if (process.env.NODE_ENV === 'development' && result === TASK_CANCEL) { | ||
log('info', name + ' has been cancelled', ''); | ||
} | ||
iterator._result = result; | ||
@@ -337,8 +343,12 @@ iterator._deferredEnd && iterator._deferredEnd.resolve(result); | ||
if (result instanceof Error) { | ||
result.sagaStack = 'at ' + name + ' \n ' + (result.sagaStack || result.stack); | ||
Object.defineProperty(result, 'sagaStack', { | ||
value: 'at ' + name + ' \n ' + (result.sagaStack || result.stack), | ||
configurable: true | ||
}); | ||
} | ||
if (!task.cont) { | ||
log('error', 'uncaught', result.sagaStack || result.stack); | ||
if (result instanceof Error && onError) { | ||
onError(result); | ||
} else { | ||
logError(result); | ||
} | ||
@@ -403,3 +413,3 @@ } | ||
} catch (err) { | ||
log('error', 'uncaught at ' + name, err.message); | ||
logError(err); | ||
} | ||
@@ -488,3 +498,3 @@ currCb.cancel = noop; // defensive measure | ||
if (channel || resolve) return cb(error, true); | ||
log('error', 'uncaught at ' + name, error.stack || error.message || error); | ||
logError(error); | ||
} | ||
@@ -660,7 +670,8 @@ | ||
} else if (!isEnd(res) && res !== CHANNEL_END && res !== TASK_CANCEL) { | ||
var _cb; | ||
var _response; | ||
cb.cancel(); | ||
completed = true; | ||
cb((_cb = {}, _cb[key] = res, _cb)); | ||
var response = (_response = {}, _response[key] = res, _response); | ||
cb(is.array(effects) ? [].slice.call(_extends({}, response, { length: keys.length })) : response); | ||
} | ||
@@ -667,0 +678,0 @@ }; |
@@ -9,8 +9,8 @@ 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 var TASK = sym('TASK'); | ||
export var HELPER = sym('HELPER'); | ||
export var MATCH = sym('MATCH'); | ||
export var CANCEL = sym('CANCEL_PROMISE'); | ||
export var SAGA_ACTION = sym('SAGA_ACTION'); | ||
export var SELF_CANCELLATION = sym('SELF_CANCELLATION'); | ||
export var TASK = /*#__PURE__*/sym('TASK'); | ||
export var HELPER = /*#__PURE__*/sym('HELPER'); | ||
export var MATCH = /*#__PURE__*/sym('MATCH'); | ||
export var CANCEL = /*#__PURE__*/sym('CANCEL_PROMISE'); | ||
export var SAGA_ACTION = /*#__PURE__*/sym('SAGA_ACTION'); | ||
export var SELF_CANCELLATION = /*#__PURE__*/sym('SELF_CANCELLATION'); | ||
export var konst = function konst(v) { | ||
@@ -21,4 +21,4 @@ return function () { | ||
}; | ||
export var kTrue = konst(true); | ||
export var kFalse = konst(false); | ||
export var kTrue = /*#__PURE__*/konst(true); | ||
export var kFalse = /*#__PURE__*/konst(false); | ||
export var noop = function noop() {}; | ||
@@ -189,3 +189,3 @@ export var ident = function ident(v) { | ||
export var uid = autoInc(); | ||
export var uid = /*#__PURE__*/autoInc(); | ||
@@ -192,0 +192,0 @@ var kThrow = function kThrow(err) { |
import {Action, Middleware} from "redux"; | ||
import {Effect, Pattern} from "./effects"; | ||
import {Effect, ForkEffect, Pattern} from "./effects"; | ||
@@ -176,2 +176,3 @@ export {Effect, Pattern}; | ||
export function detach(forkEffect: ForkEffect): ForkEffect; | ||
@@ -178,0 +179,0 @@ import * as effects from './effects'; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var _io = require('./internal/io'); | ||
var _io = /*#__PURE__*/require('./internal/io'); | ||
@@ -8,0 +8,0 @@ Object.defineProperty(exports, 'take', { |
'use strict'; | ||
exports.__esModule = true; | ||
exports.utils = exports.effects = exports.CANCEL = exports.delay = exports.throttle = exports.takeLatest = exports.takeEvery = exports.buffers = exports.channel = exports.eventChannel = exports.END = exports.runSaga = undefined; | ||
exports.utils = exports.effects = exports.detach = exports.CANCEL = exports.delay = exports.throttle = exports.takeLatest = exports.takeEvery = exports.buffers = exports.channel = exports.eventChannel = exports.END = exports.runSaga = undefined; | ||
var _runSaga = require('./internal/runSaga'); | ||
var _runSaga = /*#__PURE__*/require('./internal/runSaga'); | ||
@@ -15,3 +15,3 @@ Object.defineProperty(exports, 'runSaga', { | ||
var _channel = require('./internal/channel'); | ||
var _channel = /*#__PURE__*/require('./internal/channel'); | ||
@@ -37,3 +37,3 @@ Object.defineProperty(exports, 'END', { | ||
var _buffers = require('./internal/buffers'); | ||
var _buffers = /*#__PURE__*/require('./internal/buffers'); | ||
@@ -47,3 +47,3 @@ Object.defineProperty(exports, 'buffers', { | ||
var _sagaHelpers = require('./internal/sagaHelpers'); | ||
var _sagaHelpers = /*#__PURE__*/require('./internal/sagaHelpers'); | ||
@@ -69,3 +69,3 @@ Object.defineProperty(exports, 'takeEvery', { | ||
var _utils = require('./internal/utils'); | ||
var _utils = /*#__PURE__*/require('./internal/utils'); | ||
@@ -85,14 +85,23 @@ Object.defineProperty(exports, 'delay', { | ||
var _middleware = require('./internal/middleware'); | ||
var _io = /*#__PURE__*/require('./internal/io'); | ||
var _middleware2 = _interopRequireDefault(_middleware); | ||
Object.defineProperty(exports, 'detach', { | ||
enumerable: true, | ||
get: function get() { | ||
return _io.detach; | ||
} | ||
}); | ||
var _effects = require('./effects'); | ||
var _middleware = /*#__PURE__*/require('./internal/middleware'); | ||
var effects = _interopRequireWildcard(_effects); | ||
var _middleware2 = /*#__PURE__*/_interopRequireDefault(_middleware); | ||
var _utils2 = require('./utils'); | ||
var _effects = /*#__PURE__*/require('./effects'); | ||
var utils = _interopRequireWildcard(_utils2); | ||
var effects = /*#__PURE__*/_interopRequireWildcard(_effects); | ||
var _utils2 = /*#__PURE__*/require('./utils'); | ||
var utils = /*#__PURE__*/_interopRequireWildcard(_utils2); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -99,0 +108,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
var _utils = /*#__PURE__*/require("./utils"); | ||
@@ -9,0 +9,0 @@ var BUFFER_OVERFLOW = exports.BUFFER_OVERFLOW = "Channel's Buffer overflow!"; |
@@ -13,7 +13,7 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _utils = /*#__PURE__*/require('./utils'); | ||
var _buffers = require('./buffers'); | ||
var _buffers = /*#__PURE__*/require('./buffers'); | ||
var _scheduler = require('./scheduler'); | ||
var _scheduler = /*#__PURE__*/require('./scheduler'); | ||
@@ -20,0 +20,0 @@ var CHANNEL_END_TYPE = '@@redux-saga/CHANNEL_END'; |
'use strict'; | ||
exports.__esModule = true; | ||
exports.asEffect = exports.takem = undefined; | ||
exports.asEffect = exports.takem = exports.detach = undefined; | ||
exports.take = take; | ||
@@ -26,7 +26,7 @@ exports.put = put; | ||
var _utils = require('./utils'); | ||
var _utils = /*#__PURE__*/require('./utils'); | ||
var _sagaHelpers = require('./sagaHelpers'); | ||
var _sagaHelpers = /*#__PURE__*/require('./sagaHelpers'); | ||
var IO = (0, _utils.sym)('IO'); | ||
var IO = /*#__PURE__*/(0, _utils.sym)('IO'); | ||
var TAKE = 'TAKE'; | ||
@@ -56,2 +56,8 @@ var PUT = 'PUT'; | ||
var detach = exports.detach = function detach(eff) { | ||
(0, _utils.check)(asEffect.fork(eff), _utils.is.object, 'detach(eff): argument must be a fork effect'); | ||
eff[FORK].detached = true; | ||
return eff; | ||
}; | ||
function take() { | ||
@@ -99,3 +105,3 @@ var patternOrChannel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '*'; | ||
put.sync = (0, _utils.deprecate)(put.resolve, (0, _utils.updateIncentive)('put.sync', 'put.resolve')); | ||
put.sync = /*#__PURE__*/(0, _utils.deprecate)(put.resolve, /*#__PURE__*/(0, _utils.updateIncentive)('put.sync', 'put.resolve')); | ||
@@ -166,5 +172,3 @@ function all(effects) { | ||
var eff = fork.apply(undefined, [fn].concat(args)); | ||
eff[FORK].detached = true; | ||
return eff; | ||
return detach(fork.apply(undefined, [fn].concat(args))); | ||
} | ||
@@ -282,17 +286,17 @@ | ||
var asEffect = exports.asEffect = { | ||
take: createAsEffectType(TAKE), | ||
put: createAsEffectType(PUT), | ||
all: createAsEffectType(ALL), | ||
race: createAsEffectType(RACE), | ||
call: createAsEffectType(CALL), | ||
cps: createAsEffectType(CPS), | ||
fork: createAsEffectType(FORK), | ||
join: createAsEffectType(JOIN), | ||
cancel: createAsEffectType(CANCEL), | ||
select: createAsEffectType(SELECT), | ||
actionChannel: createAsEffectType(ACTION_CHANNEL), | ||
cancelled: createAsEffectType(CANCELLED), | ||
flush: createAsEffectType(FLUSH), | ||
getContext: createAsEffectType(GET_CONTEXT), | ||
setContext: createAsEffectType(SET_CONTEXT) | ||
take: /*#__PURE__*/createAsEffectType(TAKE), | ||
put: /*#__PURE__*/createAsEffectType(PUT), | ||
all: /*#__PURE__*/createAsEffectType(ALL), | ||
race: /*#__PURE__*/createAsEffectType(RACE), | ||
call: /*#__PURE__*/createAsEffectType(CALL), | ||
cps: /*#__PURE__*/createAsEffectType(CPS), | ||
fork: /*#__PURE__*/createAsEffectType(FORK), | ||
join: /*#__PURE__*/createAsEffectType(JOIN), | ||
cancel: /*#__PURE__*/createAsEffectType(CANCEL), | ||
select: /*#__PURE__*/createAsEffectType(SELECT), | ||
actionChannel: /*#__PURE__*/createAsEffectType(ACTION_CHANNEL), | ||
cancelled: /*#__PURE__*/createAsEffectType(CANCELLED), | ||
flush: /*#__PURE__*/createAsEffectType(FLUSH), | ||
getContext: /*#__PURE__*/createAsEffectType(GET_CONTEXT), | ||
setContext: /*#__PURE__*/createAsEffectType(SET_CONTEXT) | ||
}; |
@@ -6,7 +6,7 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _utils = /*#__PURE__*/require('./utils'); | ||
var _channel = require('./channel'); | ||
var _channel = /*#__PURE__*/require('./channel'); | ||
var _runSaga = require('./runSaga'); | ||
var _runSaga = /*#__PURE__*/require('./runSaga'); | ||
@@ -13,0 +13,0 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } |
@@ -12,11 +12,11 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _utils = /*#__PURE__*/require('./utils'); | ||
var _scheduler = require('./scheduler'); | ||
var _scheduler = /*#__PURE__*/require('./scheduler'); | ||
var _io = require('./io'); | ||
var _io = /*#__PURE__*/require('./io'); | ||
var _channel = require('./channel'); | ||
var _channel = /*#__PURE__*/require('./channel'); | ||
var _buffers = require('./buffers'); | ||
var _buffers = /*#__PURE__*/require('./buffers'); | ||
@@ -215,2 +215,11 @@ 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; } | ||
var log = logger || _utils.log; | ||
var logError = function logError(err) { | ||
var message = err.sagaStack; | ||
if (!message && err.stack) { | ||
message = err.stack.split('\n')[0].indexOf(err.message) !== -1 ? err.stack : 'Error: ' + err.message + '\n' + err.stack; | ||
} | ||
log('error', 'uncaught at ' + name, message || err.message || err); | ||
}; | ||
var stdChannel = (0, _channel.stdChannel)(subscribe); | ||
@@ -329,3 +338,3 @@ var taskContext = Object.create(parentContext); | ||
if (mainTask.isCancelled) { | ||
log('error', 'uncaught at ' + name, error.message); | ||
logError(error); | ||
} | ||
@@ -341,5 +350,2 @@ mainTask.isMainRunning = false; | ||
if (!isErr) { | ||
if (process.env.NODE_ENV === 'development' && result === TASK_CANCEL) { | ||
log('info', name + ' has been cancelled', ''); | ||
} | ||
iterator._result = result; | ||
@@ -349,8 +355,12 @@ iterator._deferredEnd && iterator._deferredEnd.resolve(result); | ||
if (result instanceof Error) { | ||
result.sagaStack = 'at ' + name + ' \n ' + (result.sagaStack || result.stack); | ||
Object.defineProperty(result, 'sagaStack', { | ||
value: 'at ' + name + ' \n ' + (result.sagaStack || result.stack), | ||
configurable: true | ||
}); | ||
} | ||
if (!task.cont) { | ||
log('error', 'uncaught', result.sagaStack || result.stack); | ||
if (result instanceof Error && onError) { | ||
onError(result); | ||
} else { | ||
logError(result); | ||
} | ||
@@ -415,3 +425,3 @@ } | ||
} catch (err) { | ||
log('error', 'uncaught at ' + name, err.message); | ||
logError(err); | ||
} | ||
@@ -500,3 +510,3 @@ currCb.cancel = _utils.noop; // defensive measure | ||
if (channel || resolve) return cb(error, true); | ||
log('error', 'uncaught at ' + name, error.stack || error.message || error); | ||
logError(error); | ||
} | ||
@@ -672,7 +682,8 @@ | ||
} else if (!(0, _channel.isEnd)(res) && res !== CHANNEL_END && res !== TASK_CANCEL) { | ||
var _cb; | ||
var _response; | ||
cb.cancel(); | ||
completed = true; | ||
cb((_cb = {}, _cb[key] = res, _cb)); | ||
var response = (_response = {}, _response[key] = res, _response); | ||
cb(_utils.is.array(effects) ? [].slice.call(_extends({}, response, { length: keys.length })) : response); | ||
} | ||
@@ -679,0 +690,0 @@ }; |
@@ -6,7 +6,7 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _utils = /*#__PURE__*/require('./utils'); | ||
var _proc = require('./proc'); | ||
var _proc = /*#__PURE__*/require('./proc'); | ||
var _proc2 = _interopRequireDefault(_proc); | ||
var _proc2 = /*#__PURE__*/_interopRequireDefault(_proc); | ||
@@ -13,0 +13,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _utils = require('../utils'); | ||
var _utils = /*#__PURE__*/require('../utils'); | ||
@@ -11,0 +11,0 @@ var done = { done: true, value: undefined }; |
@@ -6,15 +6,15 @@ 'use strict'; | ||
var _takeEvery = require('./takeEvery'); | ||
var _takeEvery = /*#__PURE__*/require('./takeEvery'); | ||
var _takeEvery2 = _interopRequireDefault(_takeEvery); | ||
var _takeEvery2 = /*#__PURE__*/_interopRequireDefault(_takeEvery); | ||
var _takeLatest = require('./takeLatest'); | ||
var _takeLatest = /*#__PURE__*/require('./takeLatest'); | ||
var _takeLatest2 = _interopRequireDefault(_takeLatest); | ||
var _takeLatest2 = /*#__PURE__*/_interopRequireDefault(_takeLatest); | ||
var _throttle = require('./throttle'); | ||
var _throttle = /*#__PURE__*/require('./throttle'); | ||
var _throttle2 = _interopRequireDefault(_throttle); | ||
var _throttle2 = /*#__PURE__*/_interopRequireDefault(_throttle); | ||
var _utils = require('../utils'); | ||
var _utils = /*#__PURE__*/require('../utils'); | ||
@@ -21,0 +21,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -6,9 +6,9 @@ 'use strict'; | ||
var _fsmIterator = require('./fsmIterator'); | ||
var _fsmIterator = /*#__PURE__*/require('./fsmIterator'); | ||
var _fsmIterator2 = _interopRequireDefault(_fsmIterator); | ||
var _fsmIterator2 = /*#__PURE__*/_interopRequireDefault(_fsmIterator); | ||
var _io = require('../io'); | ||
var _io = /*#__PURE__*/require('../io'); | ||
var _channel = require('../channel'); | ||
var _channel = /*#__PURE__*/require('../channel'); | ||
@@ -15,0 +15,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -6,9 +6,9 @@ 'use strict'; | ||
var _fsmIterator = require('./fsmIterator'); | ||
var _fsmIterator = /*#__PURE__*/require('./fsmIterator'); | ||
var _fsmIterator2 = _interopRequireDefault(_fsmIterator); | ||
var _fsmIterator2 = /*#__PURE__*/_interopRequireDefault(_fsmIterator); | ||
var _io = require('../io'); | ||
var _io = /*#__PURE__*/require('../io'); | ||
var _channel = require('../channel'); | ||
var _channel = /*#__PURE__*/require('../channel'); | ||
@@ -15,0 +15,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -6,13 +6,13 @@ 'use strict'; | ||
var _fsmIterator = require('./fsmIterator'); | ||
var _fsmIterator = /*#__PURE__*/require('./fsmIterator'); | ||
var _fsmIterator2 = _interopRequireDefault(_fsmIterator); | ||
var _fsmIterator2 = /*#__PURE__*/_interopRequireDefault(_fsmIterator); | ||
var _io = require('../io'); | ||
var _io = /*#__PURE__*/require('../io'); | ||
var _channel = require('../channel'); | ||
var _channel = /*#__PURE__*/require('../channel'); | ||
var _buffers = require('../buffers'); | ||
var _buffers = /*#__PURE__*/require('../buffers'); | ||
var _utils = require('../utils'); | ||
var _utils = /*#__PURE__*/require('../utils'); | ||
@@ -19,0 +19,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -24,8 +24,8 @@ 'use strict'; | ||
var TASK = exports.TASK = sym('TASK'); | ||
var HELPER = exports.HELPER = sym('HELPER'); | ||
var MATCH = exports.MATCH = sym('MATCH'); | ||
var CANCEL = exports.CANCEL = sym('CANCEL_PROMISE'); | ||
var SAGA_ACTION = exports.SAGA_ACTION = sym('SAGA_ACTION'); | ||
var SELF_CANCELLATION = exports.SELF_CANCELLATION = sym('SELF_CANCELLATION'); | ||
var TASK = /*#__PURE__*/exports.TASK = sym('TASK'); | ||
var HELPER = /*#__PURE__*/exports.HELPER = sym('HELPER'); | ||
var MATCH = /*#__PURE__*/exports.MATCH = sym('MATCH'); | ||
var CANCEL = /*#__PURE__*/exports.CANCEL = sym('CANCEL_PROMISE'); | ||
var SAGA_ACTION = /*#__PURE__*/exports.SAGA_ACTION = sym('SAGA_ACTION'); | ||
var SELF_CANCELLATION = /*#__PURE__*/exports.SELF_CANCELLATION = sym('SELF_CANCELLATION'); | ||
var konst = exports.konst = function konst(v) { | ||
@@ -36,4 +36,4 @@ return function () { | ||
}; | ||
var kTrue = exports.kTrue = konst(true); | ||
var kFalse = exports.kFalse = konst(false); | ||
var kTrue = /*#__PURE__*/exports.kTrue = konst(true); | ||
var kFalse = /*#__PURE__*/exports.kFalse = konst(false); | ||
var noop = exports.noop = function noop() {}; | ||
@@ -204,3 +204,3 @@ var ident = exports.ident = function ident(v) { | ||
var uid = exports.uid = autoInc(); | ||
var uid = /*#__PURE__*/exports.uid = autoInc(); | ||
@@ -207,0 +207,0 @@ var kThrow = function kThrow(err) { |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var _utils = require('./internal/utils'); | ||
var _utils = /*#__PURE__*/require('./internal/utils'); | ||
@@ -57,3 +57,3 @@ Object.defineProperty(exports, 'TASK', { | ||
var _io = require('./internal/io'); | ||
var _io = /*#__PURE__*/require('./internal/io'); | ||
@@ -67,3 +67,3 @@ Object.defineProperty(exports, 'asEffect', { | ||
var _proc = require('./internal/proc'); | ||
var _proc = /*#__PURE__*/require('./internal/proc'); | ||
@@ -70,0 +70,0 @@ Object.defineProperty(exports, 'CHANNEL_END', { |
{ | ||
"name": "redux-saga", | ||
"version": "0.15.6", | ||
"version": "0.16.0", | ||
"description": "Saga middleware for Redux to handle Side Effects", | ||
@@ -8,2 +8,11 @@ "main": "lib/index.js", | ||
"jsnext:main": "es/index.js", | ||
"unpkg": "dist/redux-saga.min.js", | ||
"files": [ | ||
"es", | ||
"lib", | ||
"dist", | ||
"effects", | ||
"utils", | ||
"*.d.ts" | ||
], | ||
"scripts": { | ||
@@ -14,3 +23,3 @@ "lint": "eslint src test", | ||
"test-src": "cross-env BABEL_ENV=cjs babel-node test/index.js | tap-spec", | ||
"check:bundlesize": "cross-env BABEL_ENV=es ./node_modules/.bin/bundlesize", | ||
"check:bundlesize": "cross-env BABEL_ENV=es bundlesize", | ||
"clean": "rimraf dist es lib", | ||
@@ -35,9 +44,9 @@ "build:umd:dev": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/redux-saga.js", | ||
"docs:publish": "npm run docs:clean && npm run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:redux-saga/redux-saga gh-pages --force", | ||
"precommit": "lint-staged && run-p build:umd:** && git add dist", | ||
"precommit": "lint-staged", | ||
"prepare": "npm run build", | ||
"prepush": "npm run check", | ||
"prerelease": "npm run check && npm run prepare", | ||
"release:patch": "npm run prerelease && npm version patch && git push --follow-tags && npm publish", | ||
"release:minor": "npm run prerelease && npm version minor && git push --follow-tags && npm publish", | ||
"release:major": "npm run prerelease && npm version major && git push --follow-tags && npm publish" | ||
"release:patch": "npm run prerelease && npm version patch && npm publish && git push --follow-tags", | ||
"release:minor": "npm run prerelease && npm version minor && npm publish && git push --follow-tags", | ||
"release:major": "npm run prerelease && npm version major && npm publish && git push --follow-tags" | ||
}, | ||
@@ -77,2 +86,3 @@ "repository": { | ||
"babel-loader": "^6.2.5", | ||
"babel-plugin-annotate-pure-calls": "^0.2.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
@@ -99,7 +109,7 @@ "babel-polyfill": "^6.7.4", | ||
"rimraf": "^2.4.3", | ||
"rollup": "^0.41.6", | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-replace": "^1.1.1", | ||
"rollup-plugin-uglify": "^1.0.2", | ||
"rollup-plugin-uglify": "^2.0.1", | ||
"tap-spec": "^4.1.1", | ||
@@ -106,0 +116,0 @@ "tape": "^4.2.2", |
@@ -5,10 +5,11 @@ <img src='https://redux-saga.js.org/logo/0800/Redux-Saga-Logo-Landscape.png' alt='Redux Logo Landscape' width='800px'> | ||
[![npm version](https://img.shields.io/npm/v/redux-saga.svg)](https://www.npmjs.com/package/redux-saga) | ||
[![CDNJS](https://img.shields.io/cdnjs/v/redux-saga.svg)](https://cdnjs.com/libraries/redux-saga) | ||
[![npm](https://img.shields.io/npm/dm/redux-saga.svg)](https://www.npmjs.com/package/redux-saga) | ||
[![Build Status](https://travis-ci.org/redux-saga/redux-saga.svg?branch=master)](https://travis-ci.org/redux-saga/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) | ||
[![OpenCollective](https://opencollective.com/redux-saga/backers/badge.svg)](#backers) | ||
[![OpenCollective](https://opencollective.com/redux-saga/sponsors/badge.svg)](#sponsors) | ||
`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. | ||
`redux-saga` is a library that aims to make application side effects (i.e. asynchronous things like data fetching and impure things like accessing the browser cache) easier to manage, more efficient to execute, simple to test, and better at handling failures. | ||
@@ -133,2 +134,3 @@ The mental model is that a saga is like a separate thread in your application that's solely responsible for side effects. `redux-saga` is a redux middleware, which means this thread can be started, paused and cancelled from the main application with normal redux actions, it has access to the full redux application state and it can dispatch redux actions as well. | ||
- [Korean](https://github.com/mskims/redux-saga-in-korean) | ||
- [Portuguese](https://github.com/joelbarbosa/redux-saga-pt_BR) | ||
- [Russian](https://github.com/redux-saga/redux-saga/blob/master/README_ru.md) | ||
@@ -138,3 +140,3 @@ | ||
There is also a **umd** build of `redux-saga` available in the `dist/` folder. When using the umd build `redux-saga` is available as `ReduxSaga` in the window object. This enables you to create Saga middleware without using ES6 `import` sytnax like this: | ||
There is also a **umd** build of `redux-saga` available in the `dist/` folder. When using the umd build `redux-saga` is available as `ReduxSaga` in the window object. This enables you to create Saga middleware without using ES6 `import` syntax like this: | ||
@@ -152,6 +154,6 @@ ```javascript | ||
**Important!** If the browser you are targeting doesn't support *ES2015 generators*, you must provide a valid polyfill, such as [the one provided by `babel`](https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser-polyfill.min.js). The polyfill must be imported before **redux-saga**: | ||
**Important!** If the browser you are targeting doesn't support *ES2015 generators*, you must transpile them (i.e. with [babel plugin](https://github.com/facebook/regenerator/tree/master/packages/regenerator-transform)) and provide a valid runtime, such as [the one here](https://unpkg.com/regenerator-runtime/runtime.js). The runtime must be imported before **redux-saga**: | ||
```javascript | ||
import 'babel-polyfill' | ||
import 'regenerator-runtime/runtime' | ||
// then | ||
@@ -158,0 +160,0 @@ import sagaMiddleware from 'redux-saga' |
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
305
8
275337
38
42
6487