UNPKG

@goldsam/ng-golden-layout

Version:
82 lines 2.87 kB
import { Inject, Injectable, Optional } from '@angular/core'; import { GoldenLayoutConfiguration } from './config'; import { GoldenLayoutStateStore } from './state'; var GoldenLayoutService = (function () { /** * @param {?} config * @param {?} stateStore */ function GoldenLayoutService(config, stateStore) { this.config = config; this.stateStore = stateStore; } /** * @param {?} goldenLayout * @param {?} componentInitCallbackFactory * @return {?} */ GoldenLayoutService.prototype.initialize = function (goldenLayout, componentInitCallbackFactory) { var _this = this; this.config.components.forEach(function (componentConfig) { var /** @type {?} */ componentInitCallback = componentInitCallbackFactory.createComponentInitCallback(componentConfig.component); goldenLayout.registerComponent(componentConfig.componentName, componentInitCallback); }); if (this.stateStore) { ((((goldenLayout)))).on('stateChanged', function () { _this._saveState(goldenLayout); }); } }; /** * @param {?} goldenLayout * @return {?} */ GoldenLayoutService.prototype._saveState = function (goldenLayout) { if (this.stateStore && goldenLayout.isInitialised) { try { this.stateStore.writeState(goldenLayout.toConfig()); } catch (ex) { // Workaround for https://github.com/deepstreamIO/golden-layout/issues/192 } } }; /** * @return {?} */ GoldenLayoutService.prototype.getState = function () { var _this = this; if (this.stateStore) { return this.stateStore.loadState().catch(function () { return _this.config.defaultLayout; }); } return Promise.resolve(this.config.defaultLayout); }; return GoldenLayoutService; }()); export { GoldenLayoutService }; GoldenLayoutService.decorators = [ { type: Injectable }, ]; /** * @nocollapse */ GoldenLayoutService.ctorParameters = function () { return [ { type: GoldenLayoutConfiguration, decorators: [{ type: Inject, args: [GoldenLayoutConfiguration,] },] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [GoldenLayoutStateStore,] },] }, ]; }; function GoldenLayoutService_tsickle_Closure_declarations() { /** @type {?} */ GoldenLayoutService.decorators; /** * @nocollapse * @type {?} */ GoldenLayoutService.ctorParameters; /** @type {?} */ GoldenLayoutService.prototype.config; /** @type {?} */ GoldenLayoutService.prototype.stateStore; } //# sourceMappingURL=golden-layout.service.js.map