From 6db8983248c2602f1f0f6963094617f29b7112b9 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Tue, 27 Nov 2018 14:19:02 -0800
Subject: [PATCH] added .remove method to registries

---
 src/mol-plugin/behavior/dynamic/custom-props.ts | 5 +----
 src/mol-repr/representation.ts                  | 5 +++++
 src/mol-theme/color.ts                          | 5 +++++
 src/mol-theme/size.ts                           | 5 +++++
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/mol-plugin/behavior/dynamic/custom-props.ts b/src/mol-plugin/behavior/dynamic/custom-props.ts
index d82ae6dac..3b4c6f941 100644
--- a/src/mol-plugin/behavior/dynamic/custom-props.ts
+++ b/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: () => ({
diff --git a/src/mol-repr/representation.ts b/src/mol-repr/representation.ts
index 8a3374956..0644bd17a 100644
--- a/src/mol-repr/representation.ts
+++ b/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>
     }
diff --git a/src/mol-theme/color.ts b/src/mol-theme/color.ts
index 2368ecae7..e01bf5a66 100644
--- a/src/mol-theme/color.ts
+++ b/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>
         }
diff --git a/src/mol-theme/size.ts b/src/mol-theme/size.ts
index 66da14ada..fe5a3a352 100644
--- a/src/mol-theme/size.ts
+++ b/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>
         }
-- 
GitLab