@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) • 4.46 kB
JavaScript
import _newArrowCheck from"babel-runtime/helpers/newArrowCheck";import"phoenix";import _extends from"babel-runtime/helpers/extends";import{errorsToString,requestToCompat}from"@jumpn/utils-graphql";import{hasIn,map}from"@jumpn/utils-composite";import{remove,replace}from"@jumpn/utils-array";var _this$1=void 0,handlePush=function(n,r){return _newArrowCheck(this,_this$1),n.receive("ok",r.onSucceed).receive("error",r.onError).receive("timeout",r.onTimeout)}.bind(void 0),_this$3=void 0,getNotifier=function(n,r){return _newArrowCheck(this,_this$3),function(i){return _newArrowCheck(this,_this$3),i[n]&&i[n](r)}.bind(this)}.bind(void 0),getHandlerName=function(n){return _newArrowCheck(this,_this$3),"on"+String(n)}.bind(void 0),notify=function(n,r,i){return _newArrowCheck(this,_this$3),n.observers.forEach(getNotifier(getHandlerName(r),i))}.bind(void 0),_this$2=void 0,notifyall=function(n,r,i){return _newArrowCheck(this,_this$2),n.forEach(function(n){return _newArrowCheck(this,_this$2),notify(n,r,i)}.bind(this))}.bind(void 0),_this$6=void 0,find=function(n,r,i){return _newArrowCheck(this,_this$6),n.find(hasIn([r],i))}.bind(void 0),_this$5=void 0,createEventHandler=function(n,r){return _newArrowCheck(this,_this$5),function(i){return _newArrowCheck(this,_this$5),function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];_newArrowCheck(this,_this$5);var s=find(n.notifiers,"request",r);s&&i.apply(void 0,[n,s].concat(t))}.bind(this)}.bind(this)}.bind(void 0),createPushHandler=function(n,r,i){return _newArrowCheck(this,_this$5),map(createEventHandler(r,i),n)}.bind(void 0),_this$8=void 0,findIndex=function(n,r,i){return _newArrowCheck(this,_this$8),n.findIndex(hasIn([r],i))}.bind(void 0),_this$7=void 0,remove$1=function(n){return _newArrowCheck(this,_this$7),function(r){return _newArrowCheck(this,_this$7),remove(findIndex(r,"request",n.request),1,r)}.bind(this)}.bind(void 0),_this$9=void 0,refresh=function(n){return _newArrowCheck(this,_this$9),function(r){return _newArrowCheck(this,_this$9),replace(findIndex(r,"request",n.request),[n],r)}.bind(this)}.bind(void 0),_this$10=void 0,updateNotifiers=function(n,r){return _newArrowCheck(this,_this$10),n.notifiers=r(n.notifiers),n}.bind(void 0),_this$4=void 0,notifyStart=function(n){return _newArrowCheck(this,_this$4),notify(n,"Start",n)}.bind(void 0),onSubscriptionSucceed=function(n,r,i){var e=i.subscriptionId;_newArrowCheck(this,_this$4);var t=_extends({},r,{subscriptionId:e});updateNotifiers(n,refresh(t)),notifyStart(t)}.bind(void 0),abortRequest=function(n,r,i){_newArrowCheck(this,_this$4),updateNotifiers(n,remove$1(r)),notify(r,"Abort",i)}.bind(void 0),onError=function(n,r,i){return _newArrowCheck(this,_this$4),abortRequest(n,r,new Error(i))}.bind(void 0),onSubscriptionResponse=function(n,r,i){_newArrowCheck(this,_this$4),i.errors?onError(n,r,errorsToString(i.errors)):onSubscriptionSucceed(n,r,i)}.bind(void 0),onQueryOrMutationResponse=function(n,r,i){_newArrowCheck(this,_this$4),updateNotifiers(n,remove$1(r)),notify(r,"Result",i)}.bind(void 0),onTimeout=function(n,r){return _newArrowCheck(this,_this$4),notify(r,"Error",new Error("request: timeout"))}.bind(void 0),queryOrMutationHandler={onError:onError,onTimeout:onTimeout,onSucceed:onQueryOrMutationResponse},subcriptionHandler={onError:onError,onTimeout:onTimeout,onSucceed:onSubscriptionResponse},send=function(n,r,i){return _newArrowCheck(this,_this$4),handlePush(n.channel.push("doc",requestToCompat(r)),createPushHandler(i,n,r))}.bind(void 0),pushRequest=function(n,r){_newArrowCheck(this,_this$4),"subscription"===r.operationType?send(n,r.request,subcriptionHandler):(notifyStart(r),send(n,r.request,queryOrMutationHandler))}.bind(void 0),_this=void 0,createChannelJoinHandler=function(n){return _newArrowCheck(this,_this),{onError:function(r){return _newArrowCheck(this,_this),notifyall(n.notifiers,"Error",new Error("channel join: "+String(r)))}.bind(this),onSucceed:function(){return _newArrowCheck(this,_this),n.notifiers.forEach(function(r){return _newArrowCheck(this,_this),pushRequest(n,r)}.bind(this))}.bind(this),onTimeout:function(){return _newArrowCheck(this,_this),notifyall(n.notifiers,"Error",new Error("channel join: timeout"))}.bind(this)}}.bind(void 0),joinChannel=function(n){return _newArrowCheck(this,_this),handlePush(n.channel.join(),createChannelJoinHandler(n)),n.channelJoinCreated=!0,n}.bind(void 0);export default joinChannel;
//# sourceMappingURL=joinChannel.js.map