Add method to watch for workflows storage changes

This method will be reused throughout the code to watch for changes in
the workflows storage area, in order to present the most recent list of
workflows available.

Bug: twpowertools:74
Change-Id: I60eff85d8436e40c6912fdbb75f02f6457e4e295
diff --git a/src/workflows/workflowsStorage.js b/src/workflows/workflowsStorage.js
index 95b3583..6e10a07 100644
--- a/src/workflows/workflowsStorage.js
+++ b/src/workflows/workflowsStorage.js
@@ -4,6 +4,20 @@
 export const kWorkflowsDataKey = 'workflowsData';
 
 export default class WorkflowsStorage {
+  static watch(callback, asProtobuf = false) {
+    // Function which will be called when the watcher is initialized and every
+    // time the workflows storage changes.
+    const callOnChanged = () => {
+      this.getAll(asProtobuf).then(workflows => callback(workflows));
+    };
+
+    chrome.storage.onChanged.addListener((changes, areaName) => {
+      if (areaName == 'local' && changes[kWorkflowsDataKey]) callOnChanged();
+    });
+
+    callOnChanged();
+  }
+
   static getAll(asProtobuf = false) {
     return new Promise(res => {
       chrome.storage.local.get(kWorkflowsDataKey, items => {