ng2-cable
Version:
Easily integrate Rails' ActionCable into your Angular2/4/ionic2/3 application.
1 lines • 1.58 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs/Subject"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/map"),require("@angular/core"),require("actioncable")):"function"==typeof define&&define.amd?define(["exports","rxjs/Subject","rxjs/add/operator/filter","rxjs/add/operator/map","@angular/core","actioncable"],t):t(e["ng2-cable"]=e["ng2-cable"]||{},e.rxjs_Subject,null,e.Rx.Observable.prototype,e.ng.core,e.ActionCable)}(this,function(e,t,r,n,o,a){"use strict";var i=function(){function e(){this._eventBus=new t.Subject}return e.prototype.broadcast=function(e,t){this._eventBus.next({key:e,data:t})},e.prototype.on=function(e){return this._eventBus.asObservable().filter(function(t){return t.key===e}).map(function(e){return e.data})},e}(),c=function(){function e(e){this.broadcaster=e,this.actionCable=a}return e.prototype.subscribe=function(e,t,r){var n=this;void 0===r&&(r={}),this.setCable(e);var o=Object.assign({channel:t},r);this.subscription=this.cable.subscriptions.create(o,{received:function(e){n.broadcaster.broadcast(e.action||t,e)}})},e.prototype.setCable=function(e){this.cable=a.createConsumer(e)},e.prototype.unsubscribe=function(){this.cable.subscriptions.remove(this.subscription)},e.decorators=[{type:o.Injectable}],e.ctorParameters=function(){return[{type:i}]},e}(),s=function(){function e(){}return e.decorators=[{type:o.NgModule,args:[{providers:[c,i]}]}],e.ctorParameters=function(){return[]},e}();e.Broadcaster=i,e.Ng2Cable=c,e.Ng2CableModule=s,Object.defineProperty(e,"__esModule",{value:!0})});