{"action":"created","comment":{"url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/comments/26595573","id":26595573,"diff_hunk":"@@ -96,16 +96,38 @@ function Socket (type, opts) {\n             break;\n     }\n \n-    this.binding = nn.Socket(this.af_domain, this.protocol);\n-    this.queue = [];\n+  this.binding = nn.Socket(this.af_domain, this.protocol);\n+  this.queue = [];\n \n-    for(var sokopt in sol){\n-        if(opts.hasOwnProperty(sokopt)) this[sokopt](opts[sokopt]);\n+  /* subscription filters */\n+  this.channels = {};\n+\n+  /* subscription handling at initialization */\n+  if (opts.hasOwnProperty('chan')) {\n+    if (typeof opts.chan == 'string') {\n+      opts.chan.split(',').forEach(subscriber.bind(this))\n+    } else {","path":"lib/index.js","position":18,"original_position":18,"commit_id":"95a184f295412a2f4e43a1790a1dde6271ada6c1","original_commit_id":"95a184f295412a2f4e43a1790a1dde6271ada6c1","user":{"login":"reqshark","id":937826,"avatar_url":"https://avatars.githubusercontent.com/u/937826?v=3","gravatar_id":"","url":"https://api.github.com/users/reqshark","html_url":"https://github.com/reqshark","followers_url":"https://api.github.com/users/reqshark/followers","following_url":"https://api.github.com/users/reqshark/following{/other_user}","gists_url":"https://api.github.com/users/reqshark/gists{/gist_id}","starred_url":"https://api.github.com/users/reqshark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reqshark/subscriptions","organizations_url":"https://api.github.com/users/reqshark/orgs","repos_url":"https://api.github.com/users/reqshark/repos","events_url":"https://api.github.com/users/reqshark/events{/privacy}","received_events_url":"https://api.github.com/users/reqshark/received_events","type":"User","site_admin":false},"body":"OK but if that thing is neither String nor Array then I want that forEach to throw the process","created_at":"2015-03-17T17:33:50Z","updated_at":"2015-03-17T17:33:50Z","html_url":"https://github.com/nickdesaulniers/node-nanomsg/pull/65#discussion_r26595573","pull_request_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65","_links":{"self":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/comments/26595573"},"html":{"href":"https://github.com/nickdesaulniers/node-nanomsg/pull/65#discussion_r26595573"},"pull_request":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65"}}},"pull_request":{"url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65","id":31247891,"html_url":"https://github.com/nickdesaulniers/node-nanomsg/pull/65","diff_url":"https://github.com/nickdesaulniers/node-nanomsg/pull/65.diff","patch_url":"https://github.com/nickdesaulniers/node-nanomsg/pull/65.patch","issue_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/65","number":65,"state":"open","locked":false,"title":"pubsub: start work on the channel api","user":{"login":"reqshark","id":937826,"avatar_url":"https://avatars.githubusercontent.com/u/937826?v=3","gravatar_id":"","url":"https://api.github.com/users/reqshark","html_url":"https://github.com/reqshark","followers_url":"https://api.github.com/users/reqshark/followers","following_url":"https://api.github.com/users/reqshark/following{/other_user}","gists_url":"https://api.github.com/users/reqshark/gists{/gist_id}","starred_url":"https://api.github.com/users/reqshark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reqshark/subscriptions","organizations_url":"https://api.github.com/users/reqshark/orgs","repos_url":"https://api.github.com/users/reqshark/repos","events_url":"https://api.github.com/users/reqshark/events{/privacy}","received_events_url":"https://api.github.com/users/reqshark/received_events","type":"User","site_admin":false},"body":"#### fixes #31 and alters our pubsub API, rendering it incompatible.\r\n\r\nNew methods:\r\n\r\n### socket.chan(*comma separated list*)\r\n\r\n### socket.rmchan(*comma separated list*)\r\n\r\nso here's how the new API would remain compatible with existing subscription sockets:\r\n\r\n```diff\r\nvar sub = nano.socket('sub')\r\n\r\n+ sub.chan('')\r\n\r\nsub.on('message', function(msg){\r\n  console.log(String(msg))\r\n})\r\n```\r\n\r\nthe new API would let us do stuff like:\r\n```js\r\nvar sub = nano.socket('sub')\r\n\r\nsub.chan('AAPL', 'MSFT', 'whatever')\r\n\r\nsub.on('message', function(msg){\r\n\r\n  // only get msgs prefixed by those registered by .chan()\r\n  console.log(String(msg))\r\n})\r\n``` \r\n\r\nAlso I'd like to take advantage of `NN_SUB_UNSUBSCRIBE` like:\r\n```js\r\nsub.rmchan('MSFT', 'whatever')\r\n\r\nsub.on('message', function(msg){\r\n\r\n  // only get msgs prefixed 'AAPL' (following from snippet above)\r\n  console.log(String(msg))\r\n})\r\n```\r\n\r\nI haven't updated tests, nor added a handler for `chans` given to `opts` object at socket initialization:\r\n\r\n```js\r\nvar nano = require('nanomsg')\r\nvar sub = nano.socket('sub', {\r\n  chan: ['AAPL', 'MSFT', 'whatever']\r\n})\r\n```\r\n\r\n I will follow up and commit those two things next if this API change meets with consensus/approval.\r\n\r\nWith that, let's open the forum to all opinions/arguments in favor or against this change. ","created_at":"2015-03-16T14:28:19Z","updated_at":"2015-03-17T17:33:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ff417f4927c2d99268eee77bdf541223ab29725","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65/commits","review_comments_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65/comments","review_comment_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/65/comments","statuses_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/statuses/95a184f295412a2f4e43a1790a1dde6271ada6c1","head":{"label":"nickdesaulniers:pubsub","ref":"pubsub","sha":"95a184f295412a2f4e43a1790a1dde6271ada6c1","user":{"login":"nickdesaulniers","id":1823839,"avatar_url":"https://avatars.githubusercontent.com/u/1823839?v=3","gravatar_id":"","url":"https://api.github.com/users/nickdesaulniers","html_url":"https://github.com/nickdesaulniers","followers_url":"https://api.github.com/users/nickdesaulniers/followers","following_url":"https://api.github.com/users/nickdesaulniers/following{/other_user}","gists_url":"https://api.github.com/users/nickdesaulniers/gists{/gist_id}","starred_url":"https://api.github.com/users/nickdesaulniers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickdesaulniers/subscriptions","organizations_url":"https://api.github.com/users/nickdesaulniers/orgs","repos_url":"https://api.github.com/users/nickdesaulniers/repos","events_url":"https://api.github.com/users/nickdesaulniers/events{/privacy}","received_events_url":"https://api.github.com/users/nickdesaulniers/received_events","type":"User","site_admin":false},"repo":{"id":12425564,"name":"node-nanomsg","full_name":"nickdesaulniers/node-nanomsg","owner":{"login":"nickdesaulniers","id":1823839,"avatar_url":"https://avatars.githubusercontent.com/u/1823839?v=3","gravatar_id":"","url":"https://api.github.com/users/nickdesaulniers","html_url":"https://github.com/nickdesaulniers","followers_url":"https://api.github.com/users/nickdesaulniers/followers","following_url":"https://api.github.com/users/nickdesaulniers/following{/other_user}","gists_url":"https://api.github.com/users/nickdesaulniers/gists{/gist_id}","starred_url":"https://api.github.com/users/nickdesaulniers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickdesaulniers/subscriptions","organizations_url":"https://api.github.com/users/nickdesaulniers/orgs","repos_url":"https://api.github.com/users/nickdesaulniers/repos","events_url":"https://api.github.com/users/nickdesaulniers/events{/privacy}","received_events_url":"https://api.github.com/users/nickdesaulniers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickdesaulniers/node-nanomsg","description":"Node.js binding for nanomsg","fork":false,"url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg","forks_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/forks","keys_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/teams","hooks_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/hooks","issue_events_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/events{/number}","events_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/events","assignees_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/assignees{/user}","branches_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/branches{/branch}","tags_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/tags","blobs_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/statuses/{sha}","languages_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/languages","stargazers_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/stargazers","contributors_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/contributors","subscribers_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/subscribers","subscription_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/subscription","commits_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/contents/{+path}","compare_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/merges","archive_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/downloads","issues_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues{/number}","pulls_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls{/number}","milestones_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/milestones{/number}","notifications_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/labels{/name}","releases_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/releases{/id}","created_at":"2013-08-28T05:39:48Z","updated_at":"2015-03-17T16:41:23Z","pushed_at":"2015-03-17T04:29:14Z","git_url":"git://github.com/nickdesaulniers/node-nanomsg.git","ssh_url":"git@github.com:nickdesaulniers/node-nanomsg.git","clone_url":"https://github.com/nickdesaulniers/node-nanomsg.git","svn_url":"https://github.com/nickdesaulniers/node-nanomsg","homepage":null,"size":1793,"stargazers_count":107,"watchers_count":107,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":19,"forks":14,"open_issues":19,"watchers":107,"default_branch":"master"}},"base":{"label":"nickdesaulniers:master","ref":"master","sha":"7538bfe18202d1631ba2e378e33bdd370d5203c0","user":{"login":"nickdesaulniers","id":1823839,"avatar_url":"https://avatars.githubusercontent.com/u/1823839?v=3","gravatar_id":"","url":"https://api.github.com/users/nickdesaulniers","html_url":"https://github.com/nickdesaulniers","followers_url":"https://api.github.com/users/nickdesaulniers/followers","following_url":"https://api.github.com/users/nickdesaulniers/following{/other_user}","gists_url":"https://api.github.com/users/nickdesaulniers/gists{/gist_id}","starred_url":"https://api.github.com/users/nickdesaulniers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickdesaulniers/subscriptions","organizations_url":"https://api.github.com/users/nickdesaulniers/orgs","repos_url":"https://api.github.com/users/nickdesaulniers/repos","events_url":"https://api.github.com/users/nickdesaulniers/events{/privacy}","received_events_url":"https://api.github.com/users/nickdesaulniers/received_events","type":"User","site_admin":false},"repo":{"id":12425564,"name":"node-nanomsg","full_name":"nickdesaulniers/node-nanomsg","owner":{"login":"nickdesaulniers","id":1823839,"avatar_url":"https://avatars.githubusercontent.com/u/1823839?v=3","gravatar_id":"","url":"https://api.github.com/users/nickdesaulniers","html_url":"https://github.com/nickdesaulniers","followers_url":"https://api.github.com/users/nickdesaulniers/followers","following_url":"https://api.github.com/users/nickdesaulniers/following{/other_user}","gists_url":"https://api.github.com/users/nickdesaulniers/gists{/gist_id}","starred_url":"https://api.github.com/users/nickdesaulniers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickdesaulniers/subscriptions","organizations_url":"https://api.github.com/users/nickdesaulniers/orgs","repos_url":"https://api.github.com/users/nickdesaulniers/repos","events_url":"https://api.github.com/users/nickdesaulniers/events{/privacy}","received_events_url":"https://api.github.com/users/nickdesaulniers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickdesaulniers/node-nanomsg","description":"Node.js binding for nanomsg","fork":false,"url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg","forks_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/forks","keys_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/teams","hooks_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/hooks","issue_events_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/events{/number}","events_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/events","assignees_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/assignees{/user}","branches_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/branches{/branch}","tags_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/tags","blobs_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/statuses/{sha}","languages_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/languages","stargazers_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/stargazers","contributors_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/contributors","subscribers_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/subscribers","subscription_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/subscription","commits_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/contents/{+path}","compare_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/merges","archive_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/downloads","issues_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues{/number}","pulls_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls{/number}","milestones_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/milestones{/number}","notifications_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/labels{/name}","releases_url":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/releases{/id}","created_at":"2013-08-28T05:39:48Z","updated_at":"2015-03-17T16:41:23Z","pushed_at":"2015-03-17T04:29:14Z","git_url":"git://github.com/nickdesaulniers/node-nanomsg.git","ssh_url":"git@github.com:nickdesaulniers/node-nanomsg.git","clone_url":"https://github.com/nickdesaulniers/node-nanomsg.git","svn_url":"https://github.com/nickdesaulniers/node-nanomsg","homepage":null,"size":1793,"stargazers_count":107,"watchers_count":107,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":19,"forks":14,"open_issues":19,"watchers":107,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65"},"html":{"href":"https://github.com/nickdesaulniers/node-nanomsg/pull/65"},"issue":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/65"},"comments":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/issues/65/comments"},"review_comments":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65/comments"},"review_comment":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/pulls/65/commits"},"statuses":{"href":"https://api.github.com/repos/nickdesaulniers/node-nanomsg/statuses/95a184f295412a2f4e43a1790a1dde6271ada6c1"}}}}