{"action":"created","issue":{"url":"https://api.github.com/repos/cyclejs/cycle-core/issues/200","labels_url":"https://api.github.com/repos/cyclejs/cycle-core/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/cyclejs/cycle-core/issues/200/comments","events_url":"https://api.github.com/repos/cyclejs/cycle-core/issues/200/events","html_url":"https://github.com/cyclejs/cycle-core/issues/200","id":126940125,"number":200,"title":"run() should be synchronous","user":{"login":"staltz","id":90512,"avatar_url":"https://avatars.githubusercontent.com/u/90512?v=3","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":[{"url":"https://api.github.com/repos/cyclejs/cycle-core/labels/breaking","name":"breaking","color":"5319e7"},{"url":"https://api.github.com/repos/cyclejs/cycle-core/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-01-15T19:26:58Z","updated_at":"2016-01-16T08:47:10Z","closed_at":null,"body":"Discussion that started here https://gitter.im/cyclejs/cycle-core?at=569934f75de13b3f15e34af6\r\n\r\nThe problem is:\r\n- We may want to use sources or sinks that Cycle.run returns to inspect something\r\n- AND the main() and the drivers may run synchronously (like they do in some tests or e.g. server side rendering)\r\n\r\nCurrent solution to that is to delay (with setTimeout) actual execution internally in run(). The discussion shows hows that's not nice in some cases.\r\n\r\nOne possible solution is to scrap the `const {sinks, sources} = run(main, drivers);` API and use instead just `const subscription = run(main, drivers);`, if people need to inspect the sinks and sources, they can wrap `main` in a function `mainWithInspections` which intercepts sources and sinks.\r\n\r\nFeedback? @Frikki @TylorS \r\n\r\nAnd @Widdershin this could be relevant to `restart` since I know you were using `{sinks, sources}` from run()."},"comment":{"url":"https://api.github.com/repos/cyclejs/cycle-core/issues/comments/172173434","html_url":"https://github.com/cyclejs/cycle-core/issues/200#issuecomment-172173434","issue_url":"https://api.github.com/repos/cyclejs/cycle-core/issues/200","id":172173434,"user":{"login":"staltz","id":90512,"avatar_url":"https://avatars.githubusercontent.com/u/90512?v=3","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":"2016-01-16T08:47:10Z","updated_at":"2016-01-16T08:47:10Z","body":"And yet another option is a callback given to `run`:\r\n\r\n```js\r\nCycle.run(main, drivers, (sources, sinks) => {\r\n  // ... Use sources and sinks ...\r\n});\r\n```\r\n\r\nOther ideas please?"}}