UNPKG

@state-sync/redux-path-reducer

Version:
58 lines (57 loc) 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * This implementation just skip all events and keep silent */ var ConnectionStatusListenerSilent = /** @class */ (function () { function ConnectionStatusListenerSilent() { } ConnectionStatusListenerSilent.prototype.onConnecting = function () { }; ConnectionStatusListenerSilent.prototype.onConnected = function () { }; ConnectionStatusListenerSilent.prototype.onDisconnect = function (reconnectTimeout) { }; ConnectionStatusListenerSilent.prototype.onConfigured = function () { }; ConnectionStatusListenerSilent.prototype.onReady = function () { }; return ConnectionStatusListenerSilent; }()); exports.ConnectionStatusListenerSilent = ConnectionStatusListenerSilent; /** * Delivery connection status to the store (redux or NgRx). */ var ConnectionStatusListenerForStore = /** @class */ (function () { /** * Construct listener using provider store interface * @param {AbstractStore} storeProvider */ function ConnectionStatusListenerForStore(storeProvider) { var _this = this; this.storeProvider = storeProvider; setInterval(function () { return _this.storeProvider().dispatch({ type: '@STATE_SYNC/CONNECTION_STATUS_TICK' }); }, 1000); } ConnectionStatusListenerForStore.prototype.dispatchStatus = function (payload) { this.storeProvider().dispatch({ type: '@STATE_SYNC/CONNECTION_STATUS', payload: payload }); }; ConnectionStatusListenerForStore.prototype.onReady = function () { this.dispatchStatus({ status: 'ready' }); }; ConnectionStatusListenerForStore.prototype.onConnecting = function () { this.dispatchStatus({ status: 'connecting' }); }; ConnectionStatusListenerForStore.prototype.onConnected = function () { this.dispatchStatus({ status: 'connected' }); }; ConnectionStatusListenerForStore.prototype.onDisconnect = function (reconnectTimeout) { this.dispatchStatus({ status: 'disconnected', reconnectTimeout: reconnectTimeout }); }; ConnectionStatusListenerForStore.prototype.onConfigured = function () { this.dispatchStatus({ status: 'configured' }); }; return ConnectionStatusListenerForStore; }()); exports.ConnectionStatusListenerForStore = ConnectionStatusListenerForStore;