ソースを参照

added .remove method to registries

Alexander Rose 6 年 前
コミット
6db8983248

+ 1 - 4
src/mol-plugin/behavior/dynamic/custom-props.ts

@@ -36,7 +36,6 @@ export const PDBeStructureQualityReport = PluginBehavior.create<{ autoAttach: bo
 
             // TODO: support filtering of themes based on the input structure
             // in this case, it would check structure.models[0].customProperties.has(StructureQualityReport.Descriptor)
-            // TODO: add remove functionality
             this.ctx.structureRepresentation.themeCtx.colorThemeRegistry.add('pdbe-structure-quality-report', {
                 label: 'PDBe Structure Quality Report',
                 factory: StructureQualityReportColorTheme,
@@ -54,9 +53,7 @@ export const PDBeStructureQualityReport = PluginBehavior.create<{ autoAttach: bo
         unregister() {
             this.ctx.customModelProperties.unregister(StructureQualityReport.Descriptor.name);
             this.ctx.lociLabels.removeProvider(labelPDBeValidation);
-
-            // TODO: add remove functionality to registry
-            // this.ctx.structureRepresentation.themeCtx.colorThemeRegistry.remove('pdbe-structure-quality-report')
+            this.ctx.structureRepresentation.themeCtx.colorThemeRegistry.remove('pdbe-structure-quality-report')
         }
     },
     params: () => ({

+ 5 - 0
src/mol-repr/representation.ts

@@ -70,6 +70,11 @@ export class RepresentationRegistry<D> {
         this._map.set(name, provider)
     }
 
+    remove(name: string) {
+        this._list.splice(this._list.findIndex(e => e.name === name))
+        this._map.delete(name)
+    }
+
     get<P extends PD.Params>(name: string): RepresentationProvider<D, P> {
         return this._map.get(name) || EmptyRepresentationProvider as unknown as RepresentationProvider<D, P>
     }

+ 5 - 0
src/mol-theme/color.ts

@@ -79,6 +79,11 @@ namespace ColorTheme {
             this._map.set(name, provider)
         }
 
+        remove(name: string) {
+            this._list.splice(this._list.findIndex(e => e.name === name))
+            this._map.delete(name)
+        }
+
         get<P extends PD.Params>(name: string): Provider<P> {
             return this._map.get(name) || EmptyProvider as unknown as Provider<P>
         }

+ 5 - 0
src/mol-theme/size.ts

@@ -57,6 +57,11 @@ namespace SizeTheme {
             this._map.set(name, provider)
         }
 
+        remove(name: string) {
+            this._list.splice(this._list.findIndex(e => e.name === name))
+            this._map.delete(name)
+        }
+
         get<P extends PD.Params>(id: string) {
             return this._map.get(id) || EmptyProvider as unknown as Provider<P>
         }