@atton16/ngx-socket-io
Version:
Socket.IO module for Angular
2 lines • 2.82 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("socket.io-client")):"function"==typeof define&&define.amd?define("@atton16/ngx-socket-io",["exports","@angular/core","rxjs","rxjs/operators","socket.io-client"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).atton16=e.atton16||{},e.atton16["ngx-socket-io"]={}),e.ng.core,e.rxjs,e.rxjs.operators,e.io.client)}(this,(function(e,t,o,n,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var c=i(r),u=s(r),f=function(){function e(e){this.config=e,this.subscribersCounter={},this.eventObservables$={},this.emptyConfig={url:"",options:{}},void 0===e&&(e=this.emptyConfig);var t=e.url,o=e.options,n=c.default?c.default:u;this.ioSocket=n(t,o)}return e.prototype.of=function(e){this.ioSocket.of(e)},e.prototype.on=function(e,t){this.ioSocket.on(e,t)},e.prototype.once=function(e,t){this.ioSocket.once(e,t)},e.prototype.connect=function(){return this.ioSocket.connect()},e.prototype.disconnect=function(e){return this.ioSocket.disconnect.apply(this.ioSocket,arguments)},e.prototype.emit=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return this.ioSocket.emit.apply(this.ioSocket,arguments)},e.prototype.removeListener=function(e,t){return this.ioSocket.removeListener.apply(this.ioSocket,arguments)},e.prototype.removeAllListeners=function(e){return this.ioSocket.removeAllListeners.apply(this.ioSocket,arguments)},e.prototype.fromEvent=function(e){var t=this;return this.subscribersCounter[e]||(this.subscribersCounter[e]=0),this.subscribersCounter[e]++,this.eventObservables$[e]||(this.eventObservables$[e]=new o.Observable((function(o){var n=function(e){o.next(e)};return t.ioSocket.on(e,n),function(){t.subscribersCounter[e]--,0===t.subscribersCounter[e]&&(t.ioSocket.removeListener(e,n),delete t.eventObservables$[e])}})).pipe(n.share())),this.eventObservables$[e]},e.prototype.fromOneTimeEvent=function(e){var t=this;return new Promise((function(o){return t.once(e,o)}))},e}();function p(e){return new f(e)}var a=new t.InjectionToken("__SOCKET_IO_CONFIG__"),l=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:a,useValue:t},{provide:f,useFactory:p,deps:[a]}]}},e}();l.decorators=[{type:t.NgModule,args:[{}]}],e.Socket=f,e.SocketIoModule=l,e.ɵa=p,e.ɵb=a,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=atton16-ngx-socket-io.umd.min.js.map