{"action":"created","comment":{"url":"https://api.github.com/repos/Tradeshift/io/pulls/comments/208874105","pull_request_review_id":144755568,"id":208874105,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODg3NDEwNQ==","diff_hunk":"@@ -166,30 +169,70 @@ export function app() {\n \t\t\tappId = message.target || '';\n \t\t\ttoken = message.token || '';\n \t\t\tdebug = log('ts:io:sub:' + appId);\n-\t\t\tdebug('CONNECTED');\n+\t\t\tdebug('CONNECTED %o', message);\n+\t\t\tif (message.source) {\n+\t\t\t\tdebug('SPAWNED from %o - %O', message.source, message);\n+\t\t\t\tif (methodHandlers.has('spawn')) {\n+\t\t\t\t\t/**\n+\t\t\t\t\t * @TODO Timeout handling!\n+\t\t\t\t\t */\n+\t\t\t\t\tmethodHandlers.get('spawn').apply({}, [\n+\t\t\t\t\t\tmessage.data,\n+\t\t\t\t\t\tfunction resolve(data) {\n+\t\t\t\t\t\t\tpostMessage({\n+\t\t\t\t\t\t\t\ttype: 'SPAWN-SUCCESS',\n+\t\t\t\t\t\t\t\ttarget: message.source,\n+\t\t\t\t\t\t\t\tdata,\n+\t\t\t\t\t\t\t\ttoken\n+\t\t\t\t\t\t\t});\n+\t\t\t\t\t\t},\n+\t\t\t\t\t\tmessage.source\n+\t\t\t\t\t]);\n+\t\t\t\t} else {\n+\t\t\t\t\t// this app can't be spawned and we should send an error back to the source app\n+\t\t\t\t\tpostMessage({\n+\t\t\t\t\t\ttype: 'SPAWN-FAIL',\n+\t\t\t\t\t\ttarget: message.source,\n+\t\t\t\t\t\ttopic: message.topic,\n+\t\t\t\t\t\tdata:\n+\t\t\t\t\t\t\tmessage.target +\n+\t\t\t\t\t\t\t\" doesn't have a 'spawn' handler, it's not compatible with this SPAWN request.\",\n+\t\t\t\t\t\ttoken\n+\t\t\t\t\t});\n+\t\t\t\t}\n+\t\t\t}\n \n+\t\t\tif (flushQueue(token)) {\n+\t\t\t\tdebug('Publishing queued messages');\n+\t\t\t}\n \t\t\treturn;\n \t\t}\n \n \t\t// Call the matching handlers for the message topic.\n+\t\tif (message.type !== 'PING') {\n+\t\t\tdebug(\n+\t\t\t\t'%s (%o) from %o - %O',\n+\t\t\t\tmessage.type,\n+\t\t\t\tmessage.topic,\n+\t\t\t\tmessage.source,\n+\t\t\t\tmessage\n+\t\t\t);\n+\t\t}\n+\n \t\tswitch (message.type) {\n \t\t\tcase 'PUBLISH':\n-\t\t\t\tdebug(\n-\t\t\t\t\t'%o (%o) from %o - %O',\n-\t\t\t\t\tmessage.type,\n-\t\t\t\t\tmessage.topic,\n-\t\t\t\t\tmessage.source,\n-\t\t\t\t\tmessage\n-\t\t\t\t);\n \t\t\t\thandlersByTopic.forEach(\n \t\t\t\t\t(handlers, topic) =>\n \t\t\t\t\t\tmatchTopic(topic, message.topic) &&\n \t\t\t\t\t\thandlers.forEach(handler => handler(message))\n \t\t\t\t);\n \t\t\t\tbreak;\n \t\t\tcase 'PING':\n-\t\t\t\tpostMessage({ type: 'PONG', token });\n-\t\t\t\tbreak;\n+\t\t\t\treturn postMessage({ type: 'PONG', token });\n+\t\t\tcase 'SPAWN-SUCCESS':","path":"src/app.js","position":331,"original_position":331,"commit_id":"ec9b36c35c58623f50331bee36f3c846f9a2bd3b","original_commit_id":"ec9b36c35c58623f50331bee36f3c846f9a2bd3b","user":{"login":"upphiminn","id":820822,"node_id":"MDQ6VXNlcjgyMDgyMg==","avatar_url":"https://avatars1.githubusercontent.com/u/820822?v=4","gravatar_id":"","url":"https://api.github.com/users/upphiminn","html_url":"https://github.com/upphiminn","followers_url":"https://api.github.com/users/upphiminn/followers","following_url":"https://api.github.com/users/upphiminn/following{/other_user}","gists_url":"https://api.github.com/users/upphiminn/gists{/gist_id}","starred_url":"https://api.github.com/users/upphiminn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/upphiminn/subscriptions","organizations_url":"https://api.github.com/users/upphiminn/orgs","repos_url":"https://api.github.com/users/upphiminn/repos","events_url":"https://api.github.com/users/upphiminn/events{/privacy}","received_events_url":"https://api.github.com/users/upphiminn/received_events","type":"User","site_admin":false},"body":"SPAWN should be just a special type of CALL (has some specific parameters passed to the callee)","created_at":"2018-08-09T10:05:05Z","updated_at":"2018-08-09T10:05:39Z","html_url":"https://github.com/Tradeshift/io/pull/17#discussion_r208874105","pull_request_url":"https://api.github.com/repos/Tradeshift/io/pulls/17","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Tradeshift/io/pulls/comments/208874105"},"html":{"href":"https://github.com/Tradeshift/io/pull/17#discussion_r208874105"},"pull_request":{"href":"https://api.github.com/repos/Tradeshift/io/pulls/17"}},"in_reply_to_id":208873546},"pull_request":{"url":"https://api.github.com/repos/Tradeshift/io/pulls/17","id":205416384,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1NDE2Mzg0","html_url":"https://github.com/Tradeshift/io/pull/17","diff_url":"https://github.com/Tradeshift/io/pull/17.diff","patch_url":"https://github.com/Tradeshift/io/pull/17.patch","issue_url":"https://api.github.com/repos/Tradeshift/io/issues/17","number":17,"state":"open","locked":false,"title":" feat: SPAWN and more","user":{"login":"sampi","id":524272,"node_id":"MDQ6VXNlcjUyNDI3Mg==","avatar_url":"https://avatars2.githubusercontent.com/u/524272?v=4","gravatar_id":"","url":"https://api.github.com/users/sampi","html_url":"https://github.com/sampi","followers_url":"https://api.github.com/users/sampi/followers","following_url":"https://api.github.com/users/sampi/following{/other_user}","gists_url":"https://api.github.com/users/sampi/gists{/gist_id}","starred_url":"https://api.github.com/users/sampi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sampi/subscriptions","organizations_url":"https://api.github.com/users/sampi/orgs","repos_url":"https://api.github.com/users/sampi/repos","events_url":"https://api.github.com/users/sampi/events{/privacy}","received_events_url":"https://api.github.com/users/sampi/received_events","type":"User","site_admin":false},"body":"@wejendorp \r\n\r\n### New stuff\r\n* When running `ts.io()` multiple times, you'll get the same instance returned.\r\n* #16 Don't initialise Hub without working `appByWindow()` and `windowByApp()` methods passed.\r\n* #5 Queue messages while the App is connecting to the Hub.\r\n* Support for `ts.io().call('kill', targetWindow)` in the Hub.\r\n* First iteration of the `ts.io().call('spawn', target, data)` call in App.\r\n\r\n### Bug fixes\r\n* Fake tests are running correctly after the rename to `ts.io()`.\r\n\r\n### Changes\r\n* Heartbeat is 3333ms, an App times out after 9999ms.\r\n* Completely new API, check README.md\r\n* `async`/`await` is preferred over Promises\r\n\r\n### Whatever\r\n* Updated all dependencies.","created_at":"2018-08-01T12:57:45Z","updated_at":"2018-08-09T10:05:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a617be54d979af0b3afcb4a1a7b9316e6221b9e1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Tradeshift/io/pulls/17/commits","review_comments_url":"https://api.github.com/repos/Tradeshift/io/pulls/17/comments","review_comment_url":"https://api.github.com/repos/Tradeshift/io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Tradeshift/io/issues/17/comments","statuses_url":"https://api.github.com/repos/Tradeshift/io/statuses/ec9b36c35c58623f50331bee36f3c846f9a2bd3b","head":{"label":"Tradeshift:dsp/instances","ref":"dsp/instances","sha":"ec9b36c35c58623f50331bee36f3c846f9a2bd3b","user":{"login":"Tradeshift","id":432092,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMjA5Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/432092?v=4","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"repo":{"id":114354871,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQzNTQ4NzE=","name":"io","full_name":"Tradeshift/io","owner":{"login":"Tradeshift","id":432092,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMjA5Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/432092?v=4","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Tradeshift/io","description":"ts.io - Tradeshift App Messaging Library","fork":false,"url":"https://api.github.com/repos/Tradeshift/io","forks_url":"https://api.github.com/repos/Tradeshift/io/forks","keys_url":"https://api.github.com/repos/Tradeshift/io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tradeshift/io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tradeshift/io/teams","hooks_url":"https://api.github.com/repos/Tradeshift/io/hooks","issue_events_url":"https://api.github.com/repos/Tradeshift/io/issues/events{/number}","events_url":"https://api.github.com/repos/Tradeshift/io/events","assignees_url":"https://api.github.com/repos/Tradeshift/io/assignees{/user}","branches_url":"https://api.github.com/repos/Tradeshift/io/branches{/branch}","tags_url":"https://api.github.com/repos/Tradeshift/io/tags","blobs_url":"https://api.github.com/repos/Tradeshift/io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tradeshift/io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tradeshift/io/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tradeshift/io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tradeshift/io/statuses/{sha}","languages_url":"https://api.github.com/repos/Tradeshift/io/languages","stargazers_url":"https://api.github.com/repos/Tradeshift/io/stargazers","contributors_url":"https://api.github.com/repos/Tradeshift/io/contributors","subscribers_url":"https://api.github.com/repos/Tradeshift/io/subscribers","subscription_url":"https://api.github.com/repos/Tradeshift/io/subscription","commits_url":"https://api.github.com/repos/Tradeshift/io/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tradeshift/io/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tradeshift/io/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tradeshift/io/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tradeshift/io/contents/{+path}","compare_url":"https://api.github.com/repos/Tradeshift/io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tradeshift/io/merges","archive_url":"https://api.github.com/repos/Tradeshift/io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tradeshift/io/downloads","issues_url":"https://api.github.com/repos/Tradeshift/io/issues{/number}","pulls_url":"https://api.github.com/repos/Tradeshift/io/pulls{/number}","milestones_url":"https://api.github.com/repos/Tradeshift/io/milestones{/number}","notifications_url":"https://api.github.com/repos/Tradeshift/io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tradeshift/io/labels{/name}","releases_url":"https://api.github.com/repos/Tradeshift/io/releases{/id}","deployments_url":"https://api.github.com/repos/Tradeshift/io/deployments","created_at":"2017-12-15T09:49:46Z","updated_at":"2018-08-09T09:43:39Z","pushed_at":"2018-08-09T09:55:02Z","git_url":"git://github.com/Tradeshift/io.git","ssh_url":"git@github.com:Tradeshift/io.git","clone_url":"https://github.com/Tradeshift/io.git","svn_url":"https://github.com/Tradeshift/io","homepage":"","size":692,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"Tradeshift:master","ref":"master","sha":"925f171872683f13ccd89cd69f9e4c33d7597101","user":{"login":"Tradeshift","id":432092,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMjA5Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/432092?v=4","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"repo":{"id":114354871,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQzNTQ4NzE=","name":"io","full_name":"Tradeshift/io","owner":{"login":"Tradeshift","id":432092,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQzMjA5Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/432092?v=4","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Tradeshift/io","description":"ts.io - Tradeshift App Messaging Library","fork":false,"url":"https://api.github.com/repos/Tradeshift/io","forks_url":"https://api.github.com/repos/Tradeshift/io/forks","keys_url":"https://api.github.com/repos/Tradeshift/io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tradeshift/io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tradeshift/io/teams","hooks_url":"https://api.github.com/repos/Tradeshift/io/hooks","issue_events_url":"https://api.github.com/repos/Tradeshift/io/issues/events{/number}","events_url":"https://api.github.com/repos/Tradeshift/io/events","assignees_url":"https://api.github.com/repos/Tradeshift/io/assignees{/user}","branches_url":"https://api.github.com/repos/Tradeshift/io/branches{/branch}","tags_url":"https://api.github.com/repos/Tradeshift/io/tags","blobs_url":"https://api.github.com/repos/Tradeshift/io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tradeshift/io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tradeshift/io/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tradeshift/io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tradeshift/io/statuses/{sha}","languages_url":"https://api.github.com/repos/Tradeshift/io/languages","stargazers_url":"https://api.github.com/repos/Tradeshift/io/stargazers","contributors_url":"https://api.github.com/repos/Tradeshift/io/contributors","subscribers_url":"https://api.github.com/repos/Tradeshift/io/subscribers","subscription_url":"https://api.github.com/repos/Tradeshift/io/subscription","commits_url":"https://api.github.com/repos/Tradeshift/io/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tradeshift/io/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tradeshift/io/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tradeshift/io/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tradeshift/io/contents/{+path}","compare_url":"https://api.github.com/repos/Tradeshift/io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tradeshift/io/merges","archive_url":"https://api.github.com/repos/Tradeshift/io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tradeshift/io/downloads","issues_url":"https://api.github.com/repos/Tradeshift/io/issues{/number}","pulls_url":"https://api.github.com/repos/Tradeshift/io/pulls{/number}","milestones_url":"https://api.github.com/repos/Tradeshift/io/milestones{/number}","notifications_url":"https://api.github.com/repos/Tradeshift/io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tradeshift/io/labels{/name}","releases_url":"https://api.github.com/repos/Tradeshift/io/releases{/id}","deployments_url":"https://api.github.com/repos/Tradeshift/io/deployments","created_at":"2017-12-15T09:49:46Z","updated_at":"2018-08-09T09:43:39Z","pushed_at":"2018-08-09T09:55:02Z","git_url":"git://github.com/Tradeshift/io.git","ssh_url":"git@github.com:Tradeshift/io.git","clone_url":"https://github.com/Tradeshift/io.git","svn_url":"https://github.com/Tradeshift/io","homepage":"","size":692,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Tradeshift/io/pulls/17"},"html":{"href":"https://github.com/Tradeshift/io/pull/17"},"issue":{"href":"https://api.github.com/repos/Tradeshift/io/issues/17"},"comments":{"href":"https://api.github.com/repos/Tradeshift/io/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/Tradeshift/io/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/Tradeshift/io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Tradeshift/io/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/Tradeshift/io/statuses/ec9b36c35c58623f50331bee36f3c846f9a2bd3b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"upphiminn"}}