{"action":"created","issue":{"url":"https://api.github.com/repos/andywer/threads.js/issues/54","repository_url":"https://api.github.com/repos/andywer/threads.js","labels_url":"https://api.github.com/repos/andywer/threads.js/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/andywer/threads.js/issues/54/comments","events_url":"https://api.github.com/repos/andywer/threads.js/issues/54/events","html_url":"https://github.com/andywer/threads.js/issues/54","id":227605859,"node_id":"MDU6SXNzdWUyMjc2MDU4NTk=","number":54,"title":"Version 1.0","user":{"login":"andywer","id":1842462,"node_id":"MDQ6VXNlcjE4NDI0NjI=","avatar_url":"https://avatars0.githubusercontent.com/u/1842462?v=4","gravatar_id":"","url":"https://api.github.com/users/andywer","html_url":"https://github.com/andywer","followers_url":"https://api.github.com/users/andywer/followers","following_url":"https://api.github.com/users/andywer/following{/other_user}","gists_url":"https://api.github.com/users/andywer/gists{/gist_id}","starred_url":"https://api.github.com/users/andywer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andywer/subscriptions","organizations_url":"https://api.github.com/users/andywer/orgs","repos_url":"https://api.github.com/users/andywer/repos","events_url":"https://api.github.com/users/andywer/events{/privacy}","received_events_url":"https://api.github.com/users/andywer/received_events","type":"User","site_admin":false},"labels":[{"id":252594958,"node_id":"MDU6TGFiZWwyNTI1OTQ5NTg=","url":"https://api.github.com/repos/andywer/threads.js/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-10T08:39:17Z","updated_at":"2018-06-20T04:50:43Z","closed_at":null,"author_association":"OWNER","body":"I think the time has come to look into more-or-less rewriting `threads` with the lessons-learned in mind, making the code clearer and bumping the version to 1.0.\r\n\r\n## To Do\r\n- [ ] Focus API on observables and promises instead of event emitting\r\n  - Pool job can be promise-centric, Thread & Pool observable\r\n- [ ] Use sync, async and possibly generator functions as worker code (instead of `done` callback)\r\n- [ ] Thread API should look more like what [workerize](https://github.com/developit/workerize) does\r\n- [ ] Deduplicate browser and node worker code (might wanna use [tiny-worker](https://github.com/avoidwork/tiny-worker))\r\n- [ ] Make sure all previous features still work\r\n\r\n## Nice to have\r\n- [ ] Try to write code in a more functional, but still performance-sensitive fashion\r\n- [ ] [SharedArrayBuffer](http://2ality.com/2017/01/shared-array-buffer.html#shared-array-buffers) polyfill for node + easy usage with the lib\r\n- [ ] Nicer integration of map-reduce patterns and thread pooling\r\n- [ ] `thread.send()` and `thread.run()` are not the best names\r\n- [ ] `Pool.prototype.send()` might be better called `Pool.prototype.queue()`\r\n- [ ] Solution to clean up after finished pool job / support sending data messages and distinct metadata messages to thread/job (#48)\r\n- [ ] Turn config into something else than a singleton\r\n- [ ] Proper API docs"},"comment":{"url":"https://api.github.com/repos/andywer/threads.js/issues/comments/398623430","html_url":"https://github.com/andywer/threads.js/issues/54#issuecomment-398623430","issue_url":"https://api.github.com/repos/andywer/threads.js/issues/54","id":398623430,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODYyMzQzMA==","user":{"login":"andywer","id":1842462,"node_id":"MDQ6VXNlcjE4NDI0NjI=","avatar_url":"https://avatars0.githubusercontent.com/u/1842462?v=4","gravatar_id":"","url":"https://api.github.com/users/andywer","html_url":"https://github.com/andywer","followers_url":"https://api.github.com/users/andywer/followers","following_url":"https://api.github.com/users/andywer/following{/other_user}","gists_url":"https://api.github.com/users/andywer/gists{/gist_id}","starred_url":"https://api.github.com/users/andywer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andywer/subscriptions","organizations_url":"https://api.github.com/users/andywer/orgs","repos_url":"https://api.github.com/users/andywer/repos","events_url":"https://api.github.com/users/andywer/events{/privacy}","received_events_url":"https://api.github.com/users/andywer/received_events","type":"User","site_admin":false},"created_at":"2018-06-20T04:50:43Z","updated_at":"2018-06-20T04:50:43Z","author_association":"OWNER","body":"New API could look like that:\r\n\r\n### Basic\r\n\r\n```js\r\nimport { spawn } from 'threads'\r\n\r\nconst multiply = spawn(async (a, b) => {\r\n  return a * b\r\n})\r\n\r\nmultiply(2, 3).then(result => {\r\n  console.log(`2 x 3 = ${result}`)\r\n  multiply.kill()  // Worker would otherwise stay alive\r\n})\r\n```\r\n\r\n### Stream with Progress\r\n\r\n```js\r\nimport { spawn } from 'threads'\r\n\r\nconst create20Numbers = spawn(function () {  // <- No arrow function (!)\r\n  return this.stream(({ next, complete, error, progress }) => {  // <- tiny Observable implementation with `progress`\r\n    let yieldedNumbers = 0\r\n    for (let index = 0; index < 20; index++) {\r\n      next(Math.random())\r\n      progress(this.progress(index / 20))\r\n      yieldedNumbers++\r\n    }\r\n    if (yieldedNumbers !== 20) {\r\n      return error(new Error(`Expected to yield twenty numbers, but only seemed to yield ${yieldedNumbers}`))\r\n    }\r\n    complete()\r\n  })\r\n})\r\n\r\ncreate20Numbers().subscribe({\r\n  next (value) {\r\n    console.log(`New value:`, value)\r\n  },\r\n  complete () {\r\n    create20Numbers.kill()  // only needed to use this worker once\r\n  },\r\n  error (error) {\r\n    console.error(`Error in worker:`, error)\r\n  },\r\n  progress (progress) {\r\n    console.log(`Progress: ${Math.round(progress * 100)}%`)\r\n  }\r\n})\r\n```"}}
{"actor":{"display_login":"andywer"}}