{"action":"created","issue":{"url":"https://api.github.com/repos/jxcore/jxcore/issues/333","labels_url":"https://api.github.com/repos/jxcore/jxcore/issues/333/labels{/name}","comments_url":"https://api.github.com/repos/jxcore/jxcore/issues/333/comments","events_url":"https://api.github.com/repos/jxcore/jxcore/issues/333/events","html_url":"https://github.com/jxcore/jxcore/issues/333","id":74213373,"number":333,"title":"Returning results from async tasks","user":{"login":"zamb3zi","id":11073466,"avatar_url":"https://avatars.githubusercontent.com/u/11073466?v=3","gravatar_id":"","url":"https://api.github.com/users/zamb3zi","html_url":"https://github.com/zamb3zi","followers_url":"https://api.github.com/users/zamb3zi/followers","following_url":"https://api.github.com/users/zamb3zi/following{/other_user}","gists_url":"https://api.github.com/users/zamb3zi/gists{/gist_id}","starred_url":"https://api.github.com/users/zamb3zi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zamb3zi/subscriptions","organizations_url":"https://api.github.com/users/zamb3zi/orgs","repos_url":"https://api.github.com/users/zamb3zi/repos","events_url":"https://api.github.com/users/zamb3zi/events{/privacy}","received_events_url":"https://api.github.com/users/zamb3zi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-08T03:27:07Z","updated_at":"2015-05-08T08:41:34Z","closed_at":null,"body":"Hi, I would like to return a result to the `addTask` callback from a task which uses `process.keepAlive()` as follows:\r\n```javascript\r\nvar work = function() {\r\n\t// deep thought...\r\n\tsetTimeout(function() {\r\n\t\tvar answer = 42;\r\n\t\tprocess.release();\r\n\t}, 1000);\r\n\tprocess.keepAlive();\r\n};\r\n\r\njxcore.tasks.addTask(work, null, function(result) {\r\n\tconsole.log('answer = ' + result);\r\n});\r\n```\r\n\r\nThis doesn't seem to be possible right now without using `process.sendToMain`, but this is awkward as I have to introduce a mechanism for identifying the task that the result is coming from (see comment below).\r\nSuggestions: either add a result callback to task methods, or support `process.release(result)`. In case of the latter, these should possibly be re-branded: `tasks.persist()` and `tasks.complete(result)`. The existing `process.` is a bit confusing here.\r\nIf nothing is changed, the documentation should probably at least mention this limitation."},"comment":{"url":"https://api.github.com/repos/jxcore/jxcore/issues/comments/100155202","html_url":"https://github.com/jxcore/jxcore/issues/333#issuecomment-100155202","issue_url":"https://api.github.com/repos/jxcore/jxcore/issues/333","id":100155202,"user":{"login":"ktrzeciaknubisa","id":5946844,"avatar_url":"https://avatars.githubusercontent.com/u/5946844?v=3","gravatar_id":"","url":"https://api.github.com/users/ktrzeciaknubisa","html_url":"https://github.com/ktrzeciaknubisa","followers_url":"https://api.github.com/users/ktrzeciaknubisa/followers","following_url":"https://api.github.com/users/ktrzeciaknubisa/following{/other_user}","gists_url":"https://api.github.com/users/ktrzeciaknubisa/gists{/gist_id}","starred_url":"https://api.github.com/users/ktrzeciaknubisa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktrzeciaknubisa/subscriptions","organizations_url":"https://api.github.com/users/ktrzeciaknubisa/orgs","repos_url":"https://api.github.com/users/ktrzeciaknubisa/repos","events_url":"https://api.github.com/users/ktrzeciaknubisa/events{/privacy}","received_events_url":"https://api.github.com/users/ktrzeciaknubisa/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T08:41:34Z","updated_at":"2015-05-08T08:41:34Z","body":"Thanks @zamb3zi for sharing your thoughts. Indeed this would be an important matter to implement returning results from async tasks and yes, it is on our list, however not with an urgent priority. \r\n\r\nI guess you already saw the discussion #255 since you propose `process.release(result)`. The following is also somewhat related: #198.\r\n\r\nYour \"awkward mechanism\" does work, right?"}}