Add associates() method to state objects

Change-Id: Ie62455b7b73424502ac01e2534482a3db99225ff
diff --git a/Changes b/Changes
index 3687cf1..648cc45 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.39 2020-09-24
+0.39 2020-10-01
         - Add information on secret file to Readme.
         - Change default API endpoint to korap.ids-mannheim.de.
         - Fix label for toggle plugins.
@@ -19,6 +19,7 @@
           services.
         - Introduced *-latest.css/*-latest.js files for plugin
           assets.
+        - Add associates() method to state objects.
 
         WARNING: If you relied on the former default API endpoint
           being http://localhost:9999/, this will break your
diff --git a/dev/js/spec/stateSpec.js b/dev/js/spec/stateSpec.js
index 865691e..6a2f32a 100644
--- a/dev/js/spec/stateSpec.js
+++ b/dev/js/spec/stateSpec.js
@@ -34,14 +34,17 @@
           this.x = value;
         }
       };
-      
+
+      expect(s.associates()).toEqual(0);
       expect(s.get()).toBeFalsy();
       expect(obj1.x).toBeFalsy();
       expect(obj2.x).toBeTruthy();
 
       // Associate object with state
       s.associate(obj1);
+      expect(s.associates()).toEqual(1);
       s.associate(obj2);
+      expect(s.associates()).toEqual(2);
 
       expect(s.get()).toBeFalsy();
       expect(obj1.x).toBeFalsy();
diff --git a/dev/js/src/state.js b/dev/js/src/state.js
index 013ae10..d561a8b 100644
--- a/dev/js/src/state.js
+++ b/dev/js/src/state.js
@@ -6,6 +6,12 @@
  *
  * @author Nils Diewald
  */
+/*
+ * TODO:
+ *   Add a "roll" parameter, like "roll":["left","right","center"]
+ *   and a roll() method, that will switch through the states in the list
+ *   for flexible toggling.
+ */
 define(function () {
 
   "use strict";
@@ -59,6 +65,14 @@
      */
     get : function () {
       return this.value;
+    },
+
+
+    /**
+     * Get the number of associated objects
+     */
+    associates : function () {
+      return this._assoc.length;
     }
   }
 });