{"action":"closed","issue":{"url":"https://api.github.com/repos/asvd/jailed/issues/18","labels_url":"https://api.github.com/repos/asvd/jailed/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/asvd/jailed/issues/18/comments","events_url":"https://api.github.com/repos/asvd/jailed/issues/18/events","html_url":"https://github.com/asvd/jailed/issues/18","id":119484217,"number":18,"title":"Support promises on top of callbacks","user":{"login":"huston007","id":4318513,"avatar_url":"https://avatars.githubusercontent.com/u/4318513?v=3","gravatar_id":"","url":"https://api.github.com/users/huston007","html_url":"https://github.com/huston007","followers_url":"https://api.github.com/users/huston007/followers","following_url":"https://api.github.com/users/huston007/following{/other_user}","gists_url":"https://api.github.com/users/huston007/gists{/gist_id}","starred_url":"https://api.github.com/users/huston007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huston007/subscriptions","organizations_url":"https://api.github.com/users/huston007/orgs","repos_url":"https://api.github.com/users/huston007/repos","events_url":"https://api.github.com/users/huston007/events{/privacy}","received_events_url":"https://api.github.com/users/huston007/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-30T12:39:04Z","updated_at":"2015-11-30T14:17:42Z","closed_at":"2015-11-30T14:17:42Z","body":"Communication with child process is built on top of postMessage now, and that's why it doesn't support returning value. And we have to use that old-style callbacks to return value from function.\r\n\r\nIt would be much better to wrap that functions into promises to allow returning values as well as promises and all such things.\r\n\r\nExample of current plugin code:\r\n```javascript\r\napplication.setInterface({\r\n  getSomeValue: function (callback) {\r\n     callback(123);\r\n  },\r\n  doAsyncJob: function (callback) {\r\n     setTimeout(callback, 1000);\r\n  }\r\n});\r\n```\r\n\r\nWhat it could look like:\r\n```javascript\r\napplication.setInterface({\r\n  getSomeValue: function (callback) {\r\n     return 123; //return simple value from promise is ok\r\n  },\r\n  doAsyncJob: function () {\r\n    return new Promise(function(resolve) {\r\n     setTimeout(resolve, 1000);\r\n    });\r\n  }\r\n});\r\n```\r\n\r\nAnd then you can call plugin code from your App so easy:\r\n```javascript\r\nplugin.remote.doAsyncJob()\r\n   .then(doSomethingElse);\r\n```"}}