{"action":"opened","issue":{"url":"https://api.github.com/repos/staltz/xstream/issues/35","repository_url":"https://api.github.com/repos/staltz/xstream","labels_url":"https://api.github.com/repos/staltz/xstream/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/staltz/xstream/issues/35/comments","events_url":"https://api.github.com/repos/staltz/xstream/issues/35/events","html_url":"https://github.com/staltz/xstream/issues/35","id":154874782,"number":35,"title":"mapTo + flatten might need lazy evaluation","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/staltz/xstream/labels/issue%20is%20bug","name":"issue is bug","color":"ee0701"},{"url":"https://api.github.com/repos/staltz/xstream/labels/weight%202%20(could)","name":"weight 2 (could)","color":"dddddd"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-14T20:46:16Z","updated_at":"2016-05-14T20:46:16Z","closed_at":null,"body":"There are cases where mapTo(innerStream) is simply not the same as `map(() => innerStream)` because the former does lazy evaluation of the `innerStream` expression, which may involve the creation of a new stream, eg if `innerStream` expression was `source.compose(dropUntil(second))`.\r\n\r\nHere's an example:\r\n\r\n```diff\r\n function notBetween(first, second) {\r\n   return source => xs.merge(\r\n     source.endWhen(first),\r\n-    first.mapTo(source.compose(dropUntil(second))).flatten()\r\n+    first.map(() => source.compose(dropUntil(second))).flatten()\r\n   )\r\n }\r\n```\r\n\r\nThe `map` works but not the `mapTo`.\r\n\r\nThis bug/behavior is not a top priority, but something we should be aware of, in case someone else trips over this. "}}