{"action":"created","comment":{"url":"https://api.github.com/repos/CometVisu/CometVisu/pulls/comments/87702716","pull_request_review_id":8306728,"id":87702716,"diff_hunk":"@@ -0,0 +1,88 @@\n+/* MessageBroker.js\n+ * \n+ * copyright (c) 2010-2016, Christian Mayer and the CometVisu contributers.\n+ * \n+ * This program is free software; you can redistribute it and/or modify it\n+ * under the terms of the GNU General Public License as published by the Free\n+ * Software Foundation; either version 3 of the License, or (at your option)\n+ * any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n+ * more details.\n+ *\n+ * You should have received a copy of the GNU General Public License along\n+ * with this program; if not, write to the Free Software Foundation, Inc.,\n+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA\n+ */\n+\n+/**\n+ * Global MessageBroker for publishing/subscribing messages on defined topics\n+ *\n+ * @author Tobias Bräutigam\n+ * @since 0.10.0\n+ */\n+define([], function() {\n+  var instance;\n+\n+  function MessageBroker() {\n+\n+    this.__registry = {};\n+    // topics only fired once\n+    this.__singleEventTopics = [\"setup.dom.finished\"];\n+\n+    this.enableTestMode = function() {\n+      this.__singleEventTopics = [];\n+    };\n+\n+    this.subscribeOnce = function (topic, callback, context, priority) {\n+      this.subscribe(topic, callback, context, priority, true);\n+    };\n+\n+    this.subscribe = function (topic, callback, context, priority, once) {\n+      if (!this.__registry[topic]) {\n+        this.__registry[topic] = [];\n+      }\n+      this.__registry[topic].push([callback || this, context, priority || 0, once || false]);\n+      // sort by priority\n+      this.__registry[topic].sort(function(a, b) {\n+        return b[2] - a[2];\n+      })\n+    };\n+\n+    this.publish = function (topic) {\n+      if (this.__registry[topic]) {\n+        var remove = [];\n+        this.__registry[topic].forEach(function(entry, index) {\n+          entry[0].apply(entry[1], Array.prototype.slice.call(arguments, 1));\n+          if (entry[3] === true) {\n+            remove.push(index);\n+          }\n+        });\n+        if (this.__singleEventTopics.indexOf(topic) >= 0) {\n+          // this is a single-fire event and can only be fired once -> delete listeners\n+          delete this.__registry[topic];\n+        }\n+        else {\n+          remove.forEach(function (index) {\n+            this.__registry[topic].splice(index, 1);\n+          }, this);\n+        }\n+      }\n+    };\n+\n+    this.clear = function() {\n+      this.__registry = {};\n+    }\n+  }\n+  return {\n+    // simulate a singleton\n+    getInstance : function() {\n+      if (!instance) {\n+        instance = new MessageBroker();\n+      }\n+      return instance;\n+    }\n+  };","path":"src/lib/MessageBroker.js","position":87,"original_position":87,"commit_id":"45d05c01942b052f57346c2abc644afd5905ae8e","original_commit_id":"f51997b561c877aafbb59fcb2d3f3bcd964fe73b","user":{"login":"peuter","id":5507035,"avatar_url":"https://avatars.githubusercontent.com/u/5507035?v=3","gravatar_id":"","url":"https://api.github.com/users/peuter","html_url":"https://github.com/peuter","followers_url":"https://api.github.com/users/peuter/followers","following_url":"https://api.github.com/users/peuter/following{/other_user}","gists_url":"https://api.github.com/users/peuter/gists{/gist_id}","starred_url":"https://api.github.com/users/peuter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peuter/subscriptions","organizations_url":"https://api.github.com/users/peuter/orgs","repos_url":"https://api.github.com/users/peuter/repos","events_url":"https://api.github.com/users/peuter/events{/privacy}","received_events_url":"https://api.github.com/users/peuter/received_events","type":"User","site_admin":false},"body":"I would prefer to explicitely use the Singleton-pattern here and leave it the way it is now.","created_at":"2016-11-12T23:59:47Z","updated_at":"2016-11-12T23:59:47Z","html_url":"https://github.com/CometVisu/CometVisu/pull/445#discussion_r87702716","pull_request_url":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445","_links":{"self":{"href":"https://api.github.com/repos/CometVisu/CometVisu/pulls/comments/87702716"},"html":{"href":"https://github.com/CometVisu/CometVisu/pull/445#discussion_r87702716"},"pull_request":{"href":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445"}}},"pull_request":{"url":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445","id":90525747,"html_url":"https://github.com/CometVisu/CometVisu/pull/445","diff_url":"https://github.com/CometVisu/CometVisu/pull/445.diff","patch_url":"https://github.com/CometVisu/CometVisu/pull/445.patch","issue_url":"https://api.github.com/repos/CometVisu/CometVisu/issues/445","number":445,"state":"open","locked":false,"title":"add caching support for rendered DOM including all data needed","user":{"login":"peuter","id":5507035,"avatar_url":"https://avatars.githubusercontent.com/u/5507035?v=3","gravatar_id":"","url":"https://api.github.com/users/peuter","html_url":"https://github.com/peuter","followers_url":"https://api.github.com/users/peuter/followers","following_url":"https://api.github.com/users/peuter/following{/other_user}","gists_url":"https://api.github.com/users/peuter/gists{/gist_id}","starred_url":"https://api.github.com/users/peuter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peuter/subscriptions","organizations_url":"https://api.github.com/users/peuter/orgs","repos_url":"https://api.github.com/users/peuter/repos","events_url":"https://api.github.com/users/peuter/events{/privacy}","received_events_url":"https://api.github.com/users/peuter/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-23T19:05:03Z","updated_at":"2016-11-12T23:59:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e94890e6763cae593dc50efe697235012c49a726","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445/commits","review_comments_url":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445/comments","review_comment_url":"https://api.github.com/repos/CometVisu/CometVisu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CometVisu/CometVisu/issues/445/comments","statuses_url":"https://api.github.com/repos/CometVisu/CometVisu/statuses/45d05c01942b052f57346c2abc644afd5905ae8e","head":{"label":"CometVisu:feature/caching","ref":"feature/caching","sha":"45d05c01942b052f57346c2abc644afd5905ae8e","user":{"login":"CometVisu","id":10695760,"avatar_url":"https://avatars.githubusercontent.com/u/10695760?v=3","gravatar_id":"","url":"https://api.github.com/users/CometVisu","html_url":"https://github.com/CometVisu","followers_url":"https://api.github.com/users/CometVisu/followers","following_url":"https://api.github.com/users/CometVisu/following{/other_user}","gists_url":"https://api.github.com/users/CometVisu/gists{/gist_id}","starred_url":"https://api.github.com/users/CometVisu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CometVisu/subscriptions","organizations_url":"https://api.github.com/users/CometVisu/orgs","repos_url":"https://api.github.com/users/CometVisu/repos","events_url":"https://api.github.com/users/CometVisu/events{/privacy}","received_events_url":"https://api.github.com/users/CometVisu/received_events","type":"Organization","site_admin":false},"repo":{"id":29815410,"name":"CometVisu","full_name":"CometVisu/CometVisu","owner":{"login":"CometVisu","id":10695760,"avatar_url":"https://avatars.githubusercontent.com/u/10695760?v=3","gravatar_id":"","url":"https://api.github.com/users/CometVisu","html_url":"https://github.com/CometVisu","followers_url":"https://api.github.com/users/CometVisu/followers","following_url":"https://api.github.com/users/CometVisu/following{/other_user}","gists_url":"https://api.github.com/users/CometVisu/gists{/gist_id}","starred_url":"https://api.github.com/users/CometVisu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CometVisu/subscriptions","organizations_url":"https://api.github.com/users/CometVisu/orgs","repos_url":"https://api.github.com/users/CometVisu/repos","events_url":"https://api.github.com/users/CometVisu/events{/privacy}","received_events_url":"https://api.github.com/users/CometVisu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CometVisu/CometVisu","description":"Repository for the CometVisu building automation visualisation.","fork":false,"url":"https://api.github.com/repos/CometVisu/CometVisu","forks_url":"https://api.github.com/repos/CometVisu/CometVisu/forks","keys_url":"https://api.github.com/repos/CometVisu/CometVisu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CometVisu/CometVisu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CometVisu/CometVisu/teams","hooks_url":"https://api.github.com/repos/CometVisu/CometVisu/hooks","issue_events_url":"https://api.github.com/repos/CometVisu/CometVisu/issues/events{/number}","events_url":"https://api.github.com/repos/CometVisu/CometVisu/events","assignees_url":"https://api.github.com/repos/CometVisu/CometVisu/assignees{/user}","branches_url":"https://api.github.com/repos/CometVisu/CometVisu/branches{/branch}","tags_url":"https://api.github.com/repos/CometVisu/CometVisu/tags","blobs_url":"https://api.github.com/repos/CometVisu/CometVisu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CometVisu/CometVisu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CometVisu/CometVisu/git/refs{/sha}","trees_url":"https://api.github.com/repos/CometVisu/CometVisu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CometVisu/CometVisu/statuses/{sha}","languages_url":"https://api.github.com/repos/CometVisu/CometVisu/languages","stargazers_url":"https://api.github.com/repos/CometVisu/CometVisu/stargazers","contributors_url":"https://api.github.com/repos/CometVisu/CometVisu/contributors","subscribers_url":"https://api.github.com/repos/CometVisu/CometVisu/subscribers","subscription_url":"https://api.github.com/repos/CometVisu/CometVisu/subscription","commits_url":"https://api.github.com/repos/CometVisu/CometVisu/commits{/sha}","git_commits_url":"https://api.github.com/repos/CometVisu/CometVisu/git/commits{/sha}","comments_url":"https://api.github.com/repos/CometVisu/CometVisu/comments{/number}","issue_comment_url":"https://api.github.com/repos/CometVisu/CometVisu/issues/comments{/number}","contents_url":"https://api.github.com/repos/CometVisu/CometVisu/contents/{+path}","compare_url":"https://api.github.com/repos/CometVisu/CometVisu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CometVisu/CometVisu/merges","archive_url":"https://api.github.com/repos/CometVisu/CometVisu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CometVisu/CometVisu/downloads","issues_url":"https://api.github.com/repos/CometVisu/CometVisu/issues{/number}","pulls_url":"https://api.github.com/repos/CometVisu/CometVisu/pulls{/number}","milestones_url":"https://api.github.com/repos/CometVisu/CometVisu/milestones{/number}","notifications_url":"https://api.github.com/repos/CometVisu/CometVisu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CometVisu/CometVisu/labels{/name}","releases_url":"https://api.github.com/repos/CometVisu/CometVisu/releases{/id}","deployments_url":"https://api.github.com/repos/CometVisu/CometVisu/deployments","created_at":"2015-01-25T13:46:53Z","updated_at":"2016-10-22T16:15:40Z","pushed_at":"2016-11-12T23:02:08Z","git_url":"git://github.com/CometVisu/CometVisu.git","ssh_url":"git@github.com:CometVisu/CometVisu.git","clone_url":"https://github.com/CometVisu/CometVisu.git","svn_url":"https://github.com/CometVisu/CometVisu","homepage":"http://www.cometvisu.org/","size":103432,"stargazers_count":19,"watchers_count":19,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":49,"mirror_url":null,"open_issues_count":58,"forks":49,"open_issues":58,"watchers":19,"default_branch":"develop"}},"base":{"label":"CometVisu:develop","ref":"develop","sha":"ea8b51dd6dfebf02672890fa7b4c2f35d39210ef","user":{"login":"CometVisu","id":10695760,"avatar_url":"https://avatars.githubusercontent.com/u/10695760?v=3","gravatar_id":"","url":"https://api.github.com/users/CometVisu","html_url":"https://github.com/CometVisu","followers_url":"https://api.github.com/users/CometVisu/followers","following_url":"https://api.github.com/users/CometVisu/following{/other_user}","gists_url":"https://api.github.com/users/CometVisu/gists{/gist_id}","starred_url":"https://api.github.com/users/CometVisu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CometVisu/subscriptions","organizations_url":"https://api.github.com/users/CometVisu/orgs","repos_url":"https://api.github.com/users/CometVisu/repos","events_url":"https://api.github.com/users/CometVisu/events{/privacy}","received_events_url":"https://api.github.com/users/CometVisu/received_events","type":"Organization","site_admin":false},"repo":{"id":29815410,"name":"CometVisu","full_name":"CometVisu/CometVisu","owner":{"login":"CometVisu","id":10695760,"avatar_url":"https://avatars.githubusercontent.com/u/10695760?v=3","gravatar_id":"","url":"https://api.github.com/users/CometVisu","html_url":"https://github.com/CometVisu","followers_url":"https://api.github.com/users/CometVisu/followers","following_url":"https://api.github.com/users/CometVisu/following{/other_user}","gists_url":"https://api.github.com/users/CometVisu/gists{/gist_id}","starred_url":"https://api.github.com/users/CometVisu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CometVisu/subscriptions","organizations_url":"https://api.github.com/users/CometVisu/orgs","repos_url":"https://api.github.com/users/CometVisu/repos","events_url":"https://api.github.com/users/CometVisu/events{/privacy}","received_events_url":"https://api.github.com/users/CometVisu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CometVisu/CometVisu","description":"Repository for the CometVisu building automation visualisation.","fork":false,"url":"https://api.github.com/repos/CometVisu/CometVisu","forks_url":"https://api.github.com/repos/CometVisu/CometVisu/forks","keys_url":"https://api.github.com/repos/CometVisu/CometVisu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CometVisu/CometVisu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CometVisu/CometVisu/teams","hooks_url":"https://api.github.com/repos/CometVisu/CometVisu/hooks","issue_events_url":"https://api.github.com/repos/CometVisu/CometVisu/issues/events{/number}","events_url":"https://api.github.com/repos/CometVisu/CometVisu/events","assignees_url":"https://api.github.com/repos/CometVisu/CometVisu/assignees{/user}","branches_url":"https://api.github.com/repos/CometVisu/CometVisu/branches{/branch}","tags_url":"https://api.github.com/repos/CometVisu/CometVisu/tags","blobs_url":"https://api.github.com/repos/CometVisu/CometVisu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CometVisu/CometVisu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CometVisu/CometVisu/git/refs{/sha}","trees_url":"https://api.github.com/repos/CometVisu/CometVisu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CometVisu/CometVisu/statuses/{sha}","languages_url":"https://api.github.com/repos/CometVisu/CometVisu/languages","stargazers_url":"https://api.github.com/repos/CometVisu/CometVisu/stargazers","contributors_url":"https://api.github.com/repos/CometVisu/CometVisu/contributors","subscribers_url":"https://api.github.com/repos/CometVisu/CometVisu/subscribers","subscription_url":"https://api.github.com/repos/CometVisu/CometVisu/subscription","commits_url":"https://api.github.com/repos/CometVisu/CometVisu/commits{/sha}","git_commits_url":"https://api.github.com/repos/CometVisu/CometVisu/git/commits{/sha}","comments_url":"https://api.github.com/repos/CometVisu/CometVisu/comments{/number}","issue_comment_url":"https://api.github.com/repos/CometVisu/CometVisu/issues/comments{/number}","contents_url":"https://api.github.com/repos/CometVisu/CometVisu/contents/{+path}","compare_url":"https://api.github.com/repos/CometVisu/CometVisu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CometVisu/CometVisu/merges","archive_url":"https://api.github.com/repos/CometVisu/CometVisu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CometVisu/CometVisu/downloads","issues_url":"https://api.github.com/repos/CometVisu/CometVisu/issues{/number}","pulls_url":"https://api.github.com/repos/CometVisu/CometVisu/pulls{/number}","milestones_url":"https://api.github.com/repos/CometVisu/CometVisu/milestones{/number}","notifications_url":"https://api.github.com/repos/CometVisu/CometVisu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CometVisu/CometVisu/labels{/name}","releases_url":"https://api.github.com/repos/CometVisu/CometVisu/releases{/id}","deployments_url":"https://api.github.com/repos/CometVisu/CometVisu/deployments","created_at":"2015-01-25T13:46:53Z","updated_at":"2016-10-22T16:15:40Z","pushed_at":"2016-11-12T23:02:08Z","git_url":"git://github.com/CometVisu/CometVisu.git","ssh_url":"git@github.com:CometVisu/CometVisu.git","clone_url":"https://github.com/CometVisu/CometVisu.git","svn_url":"https://github.com/CometVisu/CometVisu","homepage":"http://www.cometvisu.org/","size":103432,"stargazers_count":19,"watchers_count":19,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":49,"mirror_url":null,"open_issues_count":58,"forks":49,"open_issues":58,"watchers":19,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445"},"html":{"href":"https://github.com/CometVisu/CometVisu/pull/445"},"issue":{"href":"https://api.github.com/repos/CometVisu/CometVisu/issues/445"},"comments":{"href":"https://api.github.com/repos/CometVisu/CometVisu/issues/445/comments"},"review_comments":{"href":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445/comments"},"review_comment":{"href":"https://api.github.com/repos/CometVisu/CometVisu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CometVisu/CometVisu/pulls/445/commits"},"statuses":{"href":"https://api.github.com/repos/CometVisu/CometVisu/statuses/45d05c01942b052f57346c2abc644afd5905ae8e"}}}}
{"actor":{"display_login":"peuter"}}