{"action":"created","issue":{"url":"https://api.github.com/repos/cyclejs/cyclejs/issues/823","repository_url":"https://api.github.com/repos/cyclejs/cyclejs","labels_url":"https://api.github.com/repos/cyclejs/cyclejs/issues/823/labels{/name}","comments_url":"https://api.github.com/repos/cyclejs/cyclejs/issues/823/comments","events_url":"https://api.github.com/repos/cyclejs/cyclejs/issues/823/events","html_url":"https://github.com/cyclejs/cyclejs/pull/823","id":336146130,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3NjY4MjUz","number":823,"title":"New run API: setupReusable","user":{"login":"staltz","id":90512,"node_id":"MDQ6VXNlcjkwNTEy","avatar_url":"https://avatars3.githubusercontent.com/u/90512?v=4","gravatar_id":"","url":"https://api.github.com/users/staltz","html_url":"https://github.com/staltz","followers_url":"https://api.github.com/users/staltz/followers","following_url":"https://api.github.com/users/staltz/following{/other_user}","gists_url":"https://api.github.com/users/staltz/gists{/gist_id}","starred_url":"https://api.github.com/users/staltz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staltz/subscriptions","organizations_url":"https://api.github.com/users/staltz/orgs","repos_url":"https://api.github.com/users/staltz/repos","events_url":"https://api.github.com/users/staltz/events{/privacy}","received_events_url":"https://api.github.com/users/staltz/received_events","type":"User","site_admin":false},"labels":[{"id":708626252,"node_id":"MDU6TGFiZWw3MDg2MjYyNTI=","url":"https://api.github.com/repos/cyclejs/cyclejs/labels/PR:%20awaiting%20review","name":"PR: awaiting review","color":"fcfc67","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-27T09:22:16Z","updated_at":"2018-06-27T21:22:26Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/cyclejs/cyclejs/pulls/823","html_url":"https://github.com/cyclejs/cyclejs/pull/823","diff_url":"https://github.com/cyclejs/cyclejs/pull/823.diff","patch_url":"https://github.com/cyclejs/cyclejs/pull/823.patch"},"body":"- [ ] There exists an issue discussing the need for this PR\r\n- [x] I added new tests for the issue I fixed or built\r\n- [x] I used `make commit` instead of `git commit`\r\n\r\nIn hacking together a way of using react-native-navigation with cyclejs, I had to build this:\r\n\r\n```typescript\r\nfunction setupReusable(drivers: Drivers): Engine {\r\n  const sinkProxies = makeSinkProxies(drivers);\r\n  const rawSources = callDrivers(drivers, sinkProxies);\r\n  const sources = adaptSources(rawSources);\r\n  const start = (sinks: Sinks) => replicateMany(sinks, sinkProxies);\r\n  return {sources, start};\r\n}\r\n```\r\n\r\nIt's basically for reusing drivers without re-instantiating drivers, for multiple main() functions:\r\n\r\n```javascript\r\nconst engine = setupReusable(drivers);\r\nconst sources = {\r\n  ...engine.sources,\r\n  screen: screensSource,\r\n  navigation: navSource,\r\n};\r\nconst sinks = main(sources);\r\nengine.start(sinks);\r\n```\r\n\r\nIt's like a partially-applied variant of `setup`:\r\n\r\n```\r\nsetup(main, drivers): {sources, sinks, run: () => Dispose}\r\nsetupReusable(drivers): {sources, run: (sinks) => Dispose}\r\n```\r\n\r\nAnd I prefer a longer name like that so to signal to people that it's not as common as `run(main, drivers): Dispose`.\r\n\r\n------\r\n\r\nHow to review this PR: the [`feat` commit](https://github.com/cyclejs/cyclejs/pull/823/commits/d58947ad908bf5fb17aabb07e91629e6ec36bd73) is the important one, the `refactor` commit is just about moving code around.\r\n"},"comment":{"url":"https://api.github.com/repos/cyclejs/cyclejs/issues/comments/400833277","html_url":"https://github.com/cyclejs/cyclejs/pull/823#issuecomment-400833277","issue_url":"https://api.github.com/repos/cyclejs/cyclejs/issues/823","id":400833277,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDgzMzI3Nw==","user":{"login":"staltz","id":90512,"node_id":"MDQ6VXNlcjkwNTEy","avatar_url":"https://avatars3.githubusercontent.com/u/90512?v=4","gravatar_id":"","url":"https://api.github.com/users/staltz","html_url":"https://github.com/staltz","followers_url":"https://api.github.com/users/staltz/followers","following_url":"https://api.github.com/users/staltz/following{/other_user}","gists_url":"https://api.github.com/users/staltz/gists{/gist_id}","starred_url":"https://api.github.com/users/staltz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staltz/subscriptions","organizations_url":"https://api.github.com/users/staltz/orgs","repos_url":"https://api.github.com/users/staltz/repos","events_url":"https://api.github.com/users/staltz/events{/privacy}","received_events_url":"https://api.github.com/users/staltz/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T21:22:26Z","updated_at":"2018-06-27T21:22:26Z","author_association":"MEMBER","body":"Fixed!"}}
{"actor":{"display_login":"staltz"}}