{"action":"created","comment":{"url":"https://api.github.com/repos/orbitjs/orbit.js/pulls/comments/43304841","id":43304841,"diff_hunk":"@@ -191,72 +191,36 @@ var Evented = {\n       return listeners;\n     },\n \n-    resolve: function(eventNames) {\n-      var listeners = this.listeners(eventNames),\n-          args = Array.prototype.slice.call(arguments, 1);\n-\n-      return new Orbit.Promise(function(resolve, reject) {\n-        var resolveEach = function() {\n-          if (listeners.length === 0) {\n-            reject();\n-          } else {\n-            var listener = listeners.shift();\n-            var response = listener[0].apply(listener[1], args);\n-\n-            if (response) {\n-              response.then(\n-                function(success) {\n-                  resolve(success);\n-                },\n-                function(error) {\n-                  resolveEach();\n-                }\n-              );\n-            } else {\n-              resolveEach();\n-            }\n-          }\n-        };\n-\n-        resolveEach();\n-      });\n+    resolve(eventNames, ...args) {\n+      const listeners = this.listeners(eventNames);\n+\n+      function resolveEach([listener, ...listeners]) {\n+        if(!listener) return;\n+\n+        return Orbit.resolve()\n+          .then(() => {\n+            const [callback, binding] = listener;\n+            return callback.apply(binding, args);\n+          })\n+          .then(result => { return result || resolveEach(listeners); })\n+          .catch(() => { return resolveEach(listeners); });\n+      }\n+\n+      return resolveEach(listeners);\n     },\n \n-    settle: function(eventNames) {\n-      var listeners = this.listeners(eventNames),\n-          args = Array.prototype.slice.call(arguments, 1);\n+    settle(eventNames, ...args) {\n+      const listeners = this.listeners(eventNames);\n \n-      return new Orbit.Promise(function(resolve) {\n-        var settleEach = function() {\n-          if (listeners.length === 0) {\n-            resolve();\n-          } else {\n-            var listener = listeners.shift();\n-            var response;\n-            try {\n-              response = listener[0].apply(listener[1], args);\n-            } catch (e) {\n-              console.error('Orbit ignored error in event listener', eventNames);\n-              console.error(e.stack || e);\n-            }\n-\n-            if (response) {\n-              return response.then(\n-                function(success) {\n-                  settleEach();\n-                },\n-                function(error) {\n-                  settleEach();\n-                }\n-              );\n-            } else {\n-              settleEach();\n-            }\n-          }\n-        };\n+      return listeners.reduce((chain, [callback, binding]) => {\n+        return chain\n+          .then(() => { return callback.apply(binding, args); })","path":"lib/orbit/evented.js","position":87,"original_position":87,"commit_id":"0e14c24e27d00f48d52bdee7689381ae5eaee673","original_commit_id":"0e14c24e27d00f48d52bdee7689381ae5eaee673","user":{"login":"opsb","id":46232,"avatar_url":"https://avatars.githubusercontent.com/u/46232?v=3","gravatar_id":"","url":"https://api.github.com/users/opsb","html_url":"https://github.com/opsb","followers_url":"https://api.github.com/users/opsb/followers","following_url":"https://api.github.com/users/opsb/following{/other_user}","gists_url":"https://api.github.com/users/opsb/gists{/gist_id}","starred_url":"https://api.github.com/users/opsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opsb/subscriptions","organizations_url":"https://api.github.com/users/opsb/orgs","repos_url":"https://api.github.com/users/opsb/repos","events_url":"https://api.github.com/users/opsb/events{/privacy}","received_events_url":"https://api.github.com/users/opsb/received_events","type":"User","site_admin":false},"body":"ha, yeah, I'd already spotted that golfing opportunity :) will put it in","created_at":"2015-10-28T19:21:12Z","updated_at":"2015-10-28T19:21:12Z","html_url":"https://github.com/orbitjs/orbit.js/pull/216#discussion_r43304841","pull_request_url":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216","_links":{"self":{"href":"https://api.github.com/repos/orbitjs/orbit.js/pulls/comments/43304841"},"html":{"href":"https://github.com/orbitjs/orbit.js/pull/216#discussion_r43304841"},"pull_request":{"href":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216"}}},"pull_request":{"url":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216","id":48653285,"html_url":"https://github.com/orbitjs/orbit.js/pull/216","diff_url":"https://github.com/orbitjs/orbit.js/pull/216.diff","patch_url":"https://github.com/orbitjs/orbit.js/pull/216.patch","issue_url":"https://api.github.com/repos/orbitjs/orbit.js/issues/216","number":216,"state":"open","locked":false,"title":"Refactor evented","user":{"login":"opsb","id":46232,"avatar_url":"https://avatars.githubusercontent.com/u/46232?v=3","gravatar_id":"","url":"https://api.github.com/users/opsb","html_url":"https://github.com/opsb","followers_url":"https://api.github.com/users/opsb/followers","following_url":"https://api.github.com/users/opsb/following{/other_user}","gists_url":"https://api.github.com/users/opsb/gists{/gist_id}","starred_url":"https://api.github.com/users/opsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opsb/subscriptions","organizations_url":"https://api.github.com/users/opsb/orgs","repos_url":"https://api.github.com/users/opsb/repos","events_url":"https://api.github.com/users/opsb/events{/privacy}","received_events_url":"https://api.github.com/users/opsb/received_events","type":"User","site_admin":false},"body":"Updated the implementations to take advantage of Promise/ES6 helpers.\r\n\r\nAlways a subjective thing but I've tried to optimise for readability (I found myself in `settle()` frequently when debugging).","created_at":"2015-10-24T10:25:32Z","updated_at":"2015-10-28T19:21:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e0e567ee6da2efb5bff2283d3c9d0473717016e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216/commits","review_comments_url":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216/comments","review_comment_url":"https://api.github.com/repos/orbitjs/orbit.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/orbitjs/orbit.js/issues/216/comments","statuses_url":"https://api.github.com/repos/orbitjs/orbit.js/statuses/0e14c24e27d00f48d52bdee7689381ae5eaee673","head":{"label":"opsb:refactor_evented","ref":"refactor_evented","sha":"0e14c24e27d00f48d52bdee7689381ae5eaee673","user":{"login":"opsb","id":46232,"avatar_url":"https://avatars.githubusercontent.com/u/46232?v=3","gravatar_id":"","url":"https://api.github.com/users/opsb","html_url":"https://github.com/opsb","followers_url":"https://api.github.com/users/opsb/followers","following_url":"https://api.github.com/users/opsb/following{/other_user}","gists_url":"https://api.github.com/users/opsb/gists{/gist_id}","starred_url":"https://api.github.com/users/opsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opsb/subscriptions","organizations_url":"https://api.github.com/users/opsb/orgs","repos_url":"https://api.github.com/users/opsb/repos","events_url":"https://api.github.com/users/opsb/events{/privacy}","received_events_url":"https://api.github.com/users/opsb/received_events","type":"User","site_admin":false},"repo":{"id":21070436,"name":"orbit.js","full_name":"opsb/orbit.js","owner":{"login":"opsb","id":46232,"avatar_url":"https://avatars.githubusercontent.com/u/46232?v=3","gravatar_id":"","url":"https://api.github.com/users/opsb","html_url":"https://github.com/opsb","followers_url":"https://api.github.com/users/opsb/followers","following_url":"https://api.github.com/users/opsb/following{/other_user}","gists_url":"https://api.github.com/users/opsb/gists{/gist_id}","starred_url":"https://api.github.com/users/opsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opsb/subscriptions","organizations_url":"https://api.github.com/users/opsb/orgs","repos_url":"https://api.github.com/users/opsb/repos","events_url":"https://api.github.com/users/opsb/events{/privacy}","received_events_url":"https://api.github.com/users/opsb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/opsb/orbit.js","description":"A standalone library for data access and synchronization","fork":true,"url":"https://api.github.com/repos/opsb/orbit.js","forks_url":"https://api.github.com/repos/opsb/orbit.js/forks","keys_url":"https://api.github.com/repos/opsb/orbit.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opsb/orbit.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opsb/orbit.js/teams","hooks_url":"https://api.github.com/repos/opsb/orbit.js/hooks","issue_events_url":"https://api.github.com/repos/opsb/orbit.js/issues/events{/number}","events_url":"https://api.github.com/repos/opsb/orbit.js/events","assignees_url":"https://api.github.com/repos/opsb/orbit.js/assignees{/user}","branches_url":"https://api.github.com/repos/opsb/orbit.js/branches{/branch}","tags_url":"https://api.github.com/repos/opsb/orbit.js/tags","blobs_url":"https://api.github.com/repos/opsb/orbit.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opsb/orbit.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opsb/orbit.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/opsb/orbit.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opsb/orbit.js/statuses/{sha}","languages_url":"https://api.github.com/repos/opsb/orbit.js/languages","stargazers_url":"https://api.github.com/repos/opsb/orbit.js/stargazers","contributors_url":"https://api.github.com/repos/opsb/orbit.js/contributors","subscribers_url":"https://api.github.com/repos/opsb/orbit.js/subscribers","subscription_url":"https://api.github.com/repos/opsb/orbit.js/subscription","commits_url":"https://api.github.com/repos/opsb/orbit.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/opsb/orbit.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/opsb/orbit.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/opsb/orbit.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/opsb/orbit.js/contents/{+path}","compare_url":"https://api.github.com/repos/opsb/orbit.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opsb/orbit.js/merges","archive_url":"https://api.github.com/repos/opsb/orbit.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opsb/orbit.js/downloads","issues_url":"https://api.github.com/repos/opsb/orbit.js/issues{/number}","pulls_url":"https://api.github.com/repos/opsb/orbit.js/pulls{/number}","milestones_url":"https://api.github.com/repos/opsb/orbit.js/milestones{/number}","notifications_url":"https://api.github.com/repos/opsb/orbit.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opsb/orbit.js/labels{/name}","releases_url":"https://api.github.com/repos/opsb/orbit.js/releases{/id}","created_at":"2014-06-21T14:30:22Z","updated_at":"2015-03-16T18:49:39Z","pushed_at":"2015-10-25T23:26:34Z","git_url":"git://github.com/opsb/orbit.js.git","ssh_url":"git@github.com:opsb/orbit.js.git","clone_url":"https://github.com/opsb/orbit.js.git","svn_url":"https://github.com/opsb/orbit.js","homepage":"","size":1604,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"orbitjs:rethink","ref":"rethink","sha":"2e971d9ca5dcbf7ac32dbf7e4738d2e1d03b6184","user":{"login":"orbitjs","id":6467259,"avatar_url":"https://avatars.githubusercontent.com/u/6467259?v=3","gravatar_id":"","url":"https://api.github.com/users/orbitjs","html_url":"https://github.com/orbitjs","followers_url":"https://api.github.com/users/orbitjs/followers","following_url":"https://api.github.com/users/orbitjs/following{/other_user}","gists_url":"https://api.github.com/users/orbitjs/gists{/gist_id}","starred_url":"https://api.github.com/users/orbitjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orbitjs/subscriptions","organizations_url":"https://api.github.com/users/orbitjs/orgs","repos_url":"https://api.github.com/users/orbitjs/repos","events_url":"https://api.github.com/users/orbitjs/events{/privacy}","received_events_url":"https://api.github.com/users/orbitjs/received_events","type":"Organization","site_admin":false},"repo":{"id":11352797,"name":"orbit.js","full_name":"orbitjs/orbit.js","owner":{"login":"orbitjs","id":6467259,"avatar_url":"https://avatars.githubusercontent.com/u/6467259?v=3","gravatar_id":"","url":"https://api.github.com/users/orbitjs","html_url":"https://github.com/orbitjs","followers_url":"https://api.github.com/users/orbitjs/followers","following_url":"https://api.github.com/users/orbitjs/following{/other_user}","gists_url":"https://api.github.com/users/orbitjs/gists{/gist_id}","starred_url":"https://api.github.com/users/orbitjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orbitjs/subscriptions","organizations_url":"https://api.github.com/users/orbitjs/orgs","repos_url":"https://api.github.com/users/orbitjs/repos","events_url":"https://api.github.com/users/orbitjs/events{/privacy}","received_events_url":"https://api.github.com/users/orbitjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/orbitjs/orbit.js","description":"Simplify the data layer in your client-side applications.","fork":false,"url":"https://api.github.com/repos/orbitjs/orbit.js","forks_url":"https://api.github.com/repos/orbitjs/orbit.js/forks","keys_url":"https://api.github.com/repos/orbitjs/orbit.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orbitjs/orbit.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orbitjs/orbit.js/teams","hooks_url":"https://api.github.com/repos/orbitjs/orbit.js/hooks","issue_events_url":"https://api.github.com/repos/orbitjs/orbit.js/issues/events{/number}","events_url":"https://api.github.com/repos/orbitjs/orbit.js/events","assignees_url":"https://api.github.com/repos/orbitjs/orbit.js/assignees{/user}","branches_url":"https://api.github.com/repos/orbitjs/orbit.js/branches{/branch}","tags_url":"https://api.github.com/repos/orbitjs/orbit.js/tags","blobs_url":"https://api.github.com/repos/orbitjs/orbit.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orbitjs/orbit.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orbitjs/orbit.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/orbitjs/orbit.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orbitjs/orbit.js/statuses/{sha}","languages_url":"https://api.github.com/repos/orbitjs/orbit.js/languages","stargazers_url":"https://api.github.com/repos/orbitjs/orbit.js/stargazers","contributors_url":"https://api.github.com/repos/orbitjs/orbit.js/contributors","subscribers_url":"https://api.github.com/repos/orbitjs/orbit.js/subscribers","subscription_url":"https://api.github.com/repos/orbitjs/orbit.js/subscription","commits_url":"https://api.github.com/repos/orbitjs/orbit.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/orbitjs/orbit.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/orbitjs/orbit.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/orbitjs/orbit.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/orbitjs/orbit.js/contents/{+path}","compare_url":"https://api.github.com/repos/orbitjs/orbit.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orbitjs/orbit.js/merges","archive_url":"https://api.github.com/repos/orbitjs/orbit.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orbitjs/orbit.js/downloads","issues_url":"https://api.github.com/repos/orbitjs/orbit.js/issues{/number}","pulls_url":"https://api.github.com/repos/orbitjs/orbit.js/pulls{/number}","milestones_url":"https://api.github.com/repos/orbitjs/orbit.js/milestones{/number}","notifications_url":"https://api.github.com/repos/orbitjs/orbit.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orbitjs/orbit.js/labels{/name}","releases_url":"https://api.github.com/repos/orbitjs/orbit.js/releases{/id}","created_at":"2013-07-11T20:52:50Z","updated_at":"2015-10-27T12:33:45Z","pushed_at":"2015-10-25T23:26:35Z","git_url":"git://github.com/orbitjs/orbit.js.git","ssh_url":"git@github.com:orbitjs/orbit.js.git","clone_url":"https://github.com/orbitjs/orbit.js.git","svn_url":"https://github.com/orbitjs/orbit.js","homepage":"","size":3889,"stargazers_count":1375,"watchers_count":1375,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":70,"mirror_url":null,"open_issues_count":50,"forks":70,"open_issues":50,"watchers":1375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216"},"html":{"href":"https://github.com/orbitjs/orbit.js/pull/216"},"issue":{"href":"https://api.github.com/repos/orbitjs/orbit.js/issues/216"},"comments":{"href":"https://api.github.com/repos/orbitjs/orbit.js/issues/216/comments"},"review_comments":{"href":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216/comments"},"review_comment":{"href":"https://api.github.com/repos/orbitjs/orbit.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/orbitjs/orbit.js/pulls/216/commits"},"statuses":{"href":"https://api.github.com/repos/orbitjs/orbit.js/statuses/0e14c24e27d00f48d52bdee7689381ae5eaee673"}}}}