GitHub PullRequestReviewCommentEvent at 2014-03-01 23:53:25
Repository: gabilen.github.io
Actor: kbarabash
Payload: {"comment":{"url":"https://api.github.com/repos/gabilen/gabilen.github.io/pulls/comments/10193256","id":10193256,"diff_hunk":"@@ -0,0 +1,75 @@\n+/**\n+ * Class EventManager\n+ * to add events with order to initialize them,\n+ * trigger events\n+ * and delete events\n+ */\n+define([\n+    'core/core'\n+], function (core) {\n+    var EventManager = function () {\n+        this.listeners = {};\n+    };\n+    EventManager.prototype = {\n+        /**\n+         * Add new listener\n+         * @param {string} event event name\n+         * @param {function} func function to run when fire an event\n+         * @param {number} order order of event to run (optional)\n+         * @return return itself\n+         */\n+        on: function (event, func, order) {\n+            if (!this.listeners[event]) {\n+                this.listeners[event] = {};\n+            }\n+            /**\n+             * Max order of event\n+             * @param {obj} obj object to parse\n+             * @return max order count of event\n+             */\n+            var maxOrder = function (obj) {\n+                var max,\n+                    key;\n+                for (key in obj) {\n+                    if (max === undefined) {\n+                        max = key;\n+                    } else if (max < key) {\n+                        max = key;\n+                    }\n+                }\n+                return parseInt(max) || 0;\n+            };\n+            order = order || maxOrder(this.listeners[event]) + 1;","path":"js/eventManager.js","position":42,"original_position":42,"commit_id":"771ddcb7fed081047f20da2756176e97fbd81637","original_commit_id":"771ddcb7fed081047f20da2756176e97fbd81637","user":{"login":"kbarabash","id":2236400,"avatar_url":"https://avatars.githubusercontent.com/u/2236400","gravatar_id":"06a435d7983776ffc834b47f8c3849b3","url":"https://api.github.com/users/kbarabash","html_url":"https://github.com/kbarabash","followers_url":"https://api.github.com/users/kbarabash/followers","following_url":"https://api.github.com/users/kbarabash/following{/other_user}","gists_url":"https://api.github.com/users/kbarabash/gists{/gist_id}","starred_url":"https://api.github.com/users/kbarabash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbarabash/subscriptions","organizations_url":"https://api.github.com/users/kbarabash/orgs","repos_url":"https://api.github.com/users/kbarabash/repos","events_url":"https://api.github.com/users/kbarabash/events{/privacy}","received_events_url":"https://api.github.com/users/kbarabash/received_events","type":"User","site_admin":false},"body":"если order не задан, то смысла создавать функции maxOrder нет. Имеет смысл сделать if и если order не задан, то только в этом случае создать анонимную функцию и тут же выполнить её.","created_at":"2014-03-01T23:53:25Z","updated_at":"2014-03-01T23:53:25Z","html_url":"https://github.com/gabilen/gabilen.github.io/pull/9#discussion_r10193256","pull_request_url":"https://api.github.com/repos/gabilen/gabilen.github.io/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/gabilen/gabilen.github.io/pulls/comments/10193256"},"html":{"href":"https://github.com/gabilen/gabilen.github.io/pull/9#discussion_r10193256"},"pull_request":{"href":"https://api.github.com/repos/gabilen/gabilen.github.io/pulls/9"}}}}