{"action":"created","issue":{"url":"https://api.github.com/repos/zenparsing/es-observable/issues/66","labels_url":"https://api.github.com/repos/zenparsing/es-observable/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/zenparsing/es-observable/issues/66/comments","events_url":"https://api.github.com/repos/zenparsing/es-observable/issues/66/events","html_url":"https://github.com/zenparsing/es-observable/issues/66","id":114395215,"number":66,"title":"Discussion: Multicast vs. Unicast","user":{"login":"bripkens","id":596443,"avatar_url":"https://avatars.githubusercontent.com/u/596443?v=3","gravatar_id":"","url":"https://api.github.com/users/bripkens","html_url":"https://github.com/bripkens","followers_url":"https://api.github.com/users/bripkens/followers","following_url":"https://api.github.com/users/bripkens/following{/other_user}","gists_url":"https://api.github.com/users/bripkens/gists{/gist_id}","starred_url":"https://api.github.com/users/bripkens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bripkens/subscriptions","organizations_url":"https://api.github.com/users/bripkens/orgs","repos_url":"https://api.github.com/users/bripkens/repos","events_url":"https://api.github.com/users/bripkens/events{/privacy}","received_events_url":"https://api.github.com/users/bripkens/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2015-10-31T07:48:28Z","updated_at":"2015-11-03T18:14:36Z","closed_at":null,"body":"What is your stance on multicast vs. unicast for observables? Well known stream / observable implementations have varying opinions on this topic. RxJS is \"unicast\" by default [1] while Kefir [2] and Bacon [3] are multicast by default. From what I can tell based on the existing es-observable implementation, es-observable is aligned with RxJS and only provides a \"unicast\" option.\r\n\r\nNote that the RxJS' `multicast` operator does not result in the behavior of Kefir and Bacon. Kefir and Bacon retain automatic laziness and multicast enabled for all operators. The RxJS `multicast` operator only lifts the previous operator in the observable chain to a multicast one. Successive operators remain unicast.\r\n\r\nWe found multicast to be *extremely* valuable during the development of our application. We used it to model expensive operations that are executed lazily. Result are shared between all subscribers.\r\n\r\n```javascript\r\nexport const severityDistribution = allReportedIssues.map(issues => {\r\n  // do expensive work here\r\n  return severityDistribution;\r\n});\r\n```\r\n\r\n[1] http://jsbin.com/cidaheqoqa/edit?html,js,console\r\n[2] http://jsbin.com/wuqarebegi/edit?html,js,console\r\n[3] http://jsbin.com/maciradiya/edit?html,js,console\r\n"},"comment":{"url":"https://api.github.com/repos/zenparsing/es-observable/issues/comments/153441389","html_url":"https://github.com/zenparsing/es-observable/issues/66#issuecomment-153441389","issue_url":"https://api.github.com/repos/zenparsing/es-observable/issues/66","id":153441389,"user":{"login":"blesh","id":1540597,"avatar_url":"https://avatars.githubusercontent.com/u/1540597?v=3","gravatar_id":"","url":"https://api.github.com/users/blesh","html_url":"https://github.com/blesh","followers_url":"https://api.github.com/users/blesh/followers","following_url":"https://api.github.com/users/blesh/following{/other_user}","gists_url":"https://api.github.com/users/blesh/gists{/gist_id}","starred_url":"https://api.github.com/users/blesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blesh/subscriptions","organizations_url":"https://api.github.com/users/blesh/orgs","repos_url":"https://api.github.com/users/blesh/repos","events_url":"https://api.github.com/users/blesh/events{/privacy}","received_events_url":"https://api.github.com/users/blesh/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T18:14:35Z","updated_at":"2015-11-03T18:14:35Z","body":"> In what situation do you need operators to be unicast? \r\n\r\n@bripkens in cases were you want to control the number of producers set up and torn down.\r\n\r\nConsider the following: \r\n\r\n- You have an Observable that wraps an AJAX call that takes up to 5 seconds to complete.\r\n- The end point it hits gives you different responses every time you hit it.\r\n- You call it once every second and display the results as they come in.\r\n\r\n```js\r\nObservable.interval(1000).flatMap(() => longAjaxObservable)\r\n```\r\n\r\nIf all Observables were multicast the above would share the first request the following 4-5 times until it completes, then repeat the results."}}