UNPKG

@dillonkearns/elm-graphql

Version:

<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">

3 lines (2 loc) 2.77 kB
"use strict";function _interopDefault(i){return i&&"object"==typeof i&&"default"in i?i.default:i}var _newArrowCheck=_interopDefault(require("babel-runtime/helpers/newArrowCheck")),utilsComposite=require("@jumpn/utils-composite");require("phoenix");var utilsArray=require("@jumpn/utils-array"),_this$2=void 0,find=function(i,e,r){return _newArrowCheck(this,_this$2),i.find(utilsComposite.hasIn([e],r))}.bind(void 0),_this$1=void 0,createEventHandler=function(i,e){return _newArrowCheck(this,_this$1),function(r){return _newArrowCheck(this,_this$1),function(){for(var n=arguments.length,t=Array(n),o=0;o<n;o++)t[o]=arguments[o];_newArrowCheck(this,_this$1);var s=find(i.notifiers,"request",e);s&&r.apply(void 0,[i,s].concat(t))}.bind(this)}.bind(this)}.bind(void 0),createPushHandler=function(i,e,r){return _newArrowCheck(this,_this$1),utilsComposite.map(createEventHandler(e,r),i)}.bind(void 0),_this$3=void 0,handlePush=function(i,e){return _newArrowCheck(this,_this$3),i.receive("ok",e.onSucceed).receive("error",e.onError).receive("timeout",e.onTimeout)}.bind(void 0),_this$4=void 0,getNotifier=function(i,e){return _newArrowCheck(this,_this$4),function(r){return _newArrowCheck(this,_this$4),r[i]&&r[i](e)}.bind(this)}.bind(void 0),getHandlerName=function(i){return _newArrowCheck(this,_this$4),"on"+String(i)}.bind(void 0),notify=function(i,e,r){return _newArrowCheck(this,_this$4),i.observers.forEach(getNotifier(getHandlerName(e),r))}.bind(void 0),_this$6=void 0,findIndex=function(i,e,r){return _newArrowCheck(this,_this$6),i.findIndex(utilsComposite.hasIn([e],r))}.bind(void 0),_this$5=void 0,remove$1=function(i){return _newArrowCheck(this,_this$5),function(e){return _newArrowCheck(this,_this$5),utilsArray.remove(findIndex(e,"request",i.request),1,e)}.bind(this)}.bind(void 0),_this$7=void 0,updateNotifiers=function(i,e){return _newArrowCheck(this,_this$7),i.notifiers=e(i.notifiers),i}.bind(void 0),_this=void 0,removeNotifiers=function(i,e){_newArrowCheck(this,_this),updateNotifiers(i,remove$1(e)),notify(e,"Cancel",e)}.bind(void 0),onError=function(i,e,r){_newArrowCheck(this,_this),unsubscribe(i,e),notify(e,"Error","unsubscribe: "+String(r))}.bind(void 0),onTimeout=function(i,e){return _newArrowCheck(this,_this),notify(e,"Error","unsubscribe: timeout")}.bind(void 0),notifierPushHandler={onError:onError,onTimeout:onTimeout,onSucceed:removeNotifiers},unsubscribe=function(i,e){return _newArrowCheck(this,_this),handlePush(i.channel.push("unsubscribe",{subscriptionId:e.subscriptionId}),createPushHandler(notifierPushHandler,i,e.request))}.bind(void 0),cancel=function(i,e){return _newArrowCheck(this,_this),"subscription"===e.operationType?unsubscribe(i,e):removeNotifiers(i,e),i}.bind(void 0);module.exports=cancel; //# sourceMappingURL=cancel.js.map