UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

28 lines (27 loc) 924 B
export class ShareState { isBrainSerializable = true; searchComponentVisible = false; basemapComponentVisible = false; } export class ShareStateSerializer { context; syncToInterface; constructor(context, syncToInterface = false) { this.context = context; this.syncToInterface = syncToInterface; } get state() { return this.context.stateManager.state; } brainDeserialize(serialized) { const deserializedShareState = JSON.parse(serialized); this.state.extendedState.share = deserializedShareState; if (this.syncToInterface) { this.state.interface.searchComponentVisible = deserializedShareState.searchComponentVisible; this.state.interface.basemapComponentVisible = deserializedShareState.basemapComponentVisible; } } brainSerialize(shareState) { return JSON.stringify(shareState); } }