diff src/app/waveform/waveform.component.ts @ 268:9c9ac77d7448

Small refactor.
author Lucas Thompson <dev@lucas.im>
date Fri, 28 Apr 2017 15:46:23 +0100
parents 3018e8531840
children 79fa2c4c0fce
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Fri Apr 28 15:40:35 2017 +0100
+++ b/src/app/waveform/waveform.component.ts	Fri Apr 28 15:46:23 2017 +0100
@@ -32,21 +32,24 @@
 type Track = any;
 type Colour = string;
 
-const colours = function* () {
-  const circularColours = [
-    '#0868ac', // "sapphire blue", our waveform / header colour
-    '#c33c54', // "brick red"
-    '#17bebb', // "tiffany blue"
-    '#001021', // "rich black"
-    '#fa8334', // "mango tango"
-    '#034748' // "deep jungle green"
-  ];
+
+
+function* createColourGenerator(colours) {
   let index = 0;
-  const nColours = circularColours.length;
+  const nColours = colours.length;
   while (true) {
-    yield circularColours[index = ++index % nColours];
+    yield colours[index = ++index % nColours];
   }
-}();
+}
+
+const defaultColourGenerator = createColourGenerator([
+  '#0868ac', // "sapphire blue", our waveform / header colour
+  '#c33c54', // "brick red"
+  '#17bebb', // "tiffany blue"
+  '#001021', // "rich black"
+  '#fa8334', // "mango tango"
+  '#034748' // "deep jungle green"
+]);
 
 @Component({
   selector: 'ugly-waveform',
@@ -65,11 +68,11 @@
       if (this.featureExtractionSubscription) {
         return;
       }
-      
+
       this.featureExtractionSubscription =
         this.piperService.featuresExtracted$.subscribe(
           features => {
-            this.renderFeatures(features, colours.next().value);
+            this.renderFeatures(features, defaultColourGenerator.next().value);
           });
     } else {
       if (this.featureExtractionSubscription) {