Skip to content
Snippets Groups Projects
Commit 3e50377e authored by Alexander Rose's avatar Alexander Rose
Browse files

use `as const` to quickly make class props readonly

parent 3fbd1f8d
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,15 @@ import { isProductionMode, isDebugMode } from '../mol-util/debug'; ...@@ -38,6 +38,15 @@ import { isProductionMode, isDebugMode } from '../mol-util/debug';
import { Model, Structure } from '../mol-model/structure'; import { Model, Structure } from '../mol-model/structure';
import { Interaction } from './util/interaction'; import { Interaction } from './util/interaction';
interface Log {
entries: List<LogEntry>
readonly entry: (e: LogEntry) => void
readonly error: (msg: string) => void
readonly message: (msg: string) => void
readonly info: (msg: string) => void
readonly warn: (msg: string) => void
}
export class PluginContext { export class PluginContext {
private disposed = false; private disposed = false;
private ev = RxEventHelper.create(); private ev = RxEventHelper.create();
...@@ -66,7 +75,7 @@ export class PluginContext { ...@@ -66,7 +75,7 @@ export class PluginContext {
canvas3d: { canvas3d: {
settingsUpdated: this.ev() settingsUpdated: this.ev()
} }
}; } as const
readonly behaviors = { readonly behaviors = {
state: { state: {
...@@ -80,7 +89,7 @@ export class PluginContext { ...@@ -80,7 +89,7 @@ export class PluginContext {
labels: { labels: {
highlight: this.ev.behavior<{ entries: ReadonlyArray<LociLabelEntry> }>({ entries: [] }) highlight: this.ev.behavior<{ entries: ReadonlyArray<LociLabelEntry> }>({ entries: [] })
} }
}; } as const
readonly canvas3d: Canvas3D; readonly canvas3d: Canvas3D;
readonly layout: PluginLayout = new PluginLayout(this); readonly layout: PluginLayout = new PluginLayout(this);
...@@ -92,16 +101,16 @@ export class PluginContext { ...@@ -92,16 +101,16 @@ export class PluginContext {
readonly structureRepresentation = { readonly structureRepresentation = {
registry: new StructureRepresentationRegistry(), registry: new StructureRepresentationRegistry(),
themeCtx: { colorThemeRegistry: ColorTheme.createRegistry(), sizeThemeRegistry: SizeTheme.createRegistry() } as ThemeRegistryContext themeCtx: { colorThemeRegistry: ColorTheme.createRegistry(), sizeThemeRegistry: SizeTheme.createRegistry() } as ThemeRegistryContext
} } as const
readonly volumeRepresentation = { readonly volumeRepresentation = {
registry: new VolumeRepresentationRegistry(), registry: new VolumeRepresentationRegistry(),
themeCtx: { colorThemeRegistry: ColorTheme.createRegistry(), sizeThemeRegistry: SizeTheme.createRegistry() } as ThemeRegistryContext themeCtx: { colorThemeRegistry: ColorTheme.createRegistry(), sizeThemeRegistry: SizeTheme.createRegistry() } as ThemeRegistryContext
} } as const
readonly dataFormat = { readonly dataFormat = {
registry: new DataFormatRegistry() registry: new DataFormatRegistry()
} } as const
readonly customModelProperties = new CustomPropertyRegistry<Model>(); readonly customModelProperties = new CustomPropertyRegistry<Model>();
readonly customStructureProperties = new CustomPropertyRegistry<Structure>(); readonly customStructureProperties = new CustomPropertyRegistry<Structure>();
...@@ -110,7 +119,7 @@ export class PluginContext { ...@@ -110,7 +119,7 @@ export class PluginContext {
readonly helpers = { readonly helpers = {
structureSelection: new StructureElementSelectionManager(this), structureSelection: new StructureElementSelectionManager(this),
substructureParent: new SubstructureParentHelper(this) substructureParent: new SubstructureParentHelper(this)
}; } as const;
initViewer(canvas: HTMLCanvasElement, container: HTMLDivElement) { initViewer(canvas: HTMLCanvasElement, container: HTMLDivElement) {
try { try {
...@@ -128,7 +137,7 @@ export class PluginContext { ...@@ -128,7 +137,7 @@ export class PluginContext {
} }
} }
readonly log = { readonly log: Log = {
entries: List<LogEntry>(), entries: List<LogEntry>(),
entry: (e: LogEntry) => this.events.log.next(e), entry: (e: LogEntry) => this.events.log.next(e),
error: (msg: string) => this.events.log.next(LogEntry.error(msg)), error: (msg: string) => this.events.log.next(LogEntry.error(msg)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment