14 | Zone.__load_patch("fetch",(function(t,n,o){var e=t.fetch;if("function"==typeof e){var r=t[o.symbol("fetch")];r&&(e=r);var c=t.Promise,l=o.symbol("thenPatched"),a=o.symbol("fetchTaskScheduling"),f=o.symbol("fetchTaskAborting"),i=t.AbortController,u="function"==typeof i,s=null;u&&(t.AbortController=function(){var t=new i;return t.signal.abortController=t,t},s=o.patchMethod(i.prototype,"abort",(function(t){return function(n,o){return n.task?n.task.zone.cancelTask(n.task):t.apply(n,o)}})));var h=function(){};t.fetch=function(){var t=this,r=Array.prototype.slice.call(arguments),i=r.length>1?r[1]:null,b=i&&i.signal;return new Promise((function(i,d){var p=n.current.scheduleMacroTask("fetch",h,{fetchArgs:r},(function(){var f,u=n.current;try{u[a]=!0,f=e.apply(t,r)}catch(t){return void d(t)}finally{u[a]=!1}if(!(f instanceof c)){var s=f.constructor;s[l]||o.patchThen(s)}f.then((function(t){"notScheduled"!==p.state&&p.invoke(),i(t)}),(function(t){"notScheduled"!==p.state&&p.invoke(),d(t)}))}),(function(){if(u)if(b&&b.abortController&&!b.aborted&&"function"==typeof b.abortController.abort&&s)try{n.current[f]=!0,s.call(b.abortController)}finally{n.current[f]=!1}else d("cancel fetch need a AbortController.signal");else d("No AbortController supported, can not cancel fetch")}));b&&b.abortController&&(b.abortController.task=p)}))}}}))})); |
---|