{"action":"created","issue":{"url":"https://api.github.com/repos/staltz/xstream/issues/97","repository_url":"https://api.github.com/repos/staltz/xstream","labels_url":"https://api.github.com/repos/staltz/xstream/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/staltz/xstream/issues/97/comments","events_url":"https://api.github.com/repos/staltz/xstream/issues/97/events","html_url":"https://github.com/staltz/xstream/issues/97","id":168822342,"number":97,"title":"FAQ translation of RxJS' withLatestFrom not preserving semantics ","user":{"login":"tlaitinen","id":1113883,"avatar_url":"https://avatars.githubusercontent.com/u/1113883?v=3","gravatar_id":"","url":"https://api.github.com/users/tlaitinen","html_url":"https://github.com/tlaitinen","followers_url":"https://api.github.com/users/tlaitinen/followers","following_url":"https://api.github.com/users/tlaitinen/following{/other_user}","gists_url":"https://api.github.com/users/tlaitinen/gists{/gist_id}","starred_url":"https://api.github.com/users/tlaitinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlaitinen/subscriptions","organizations_url":"https://api.github.com/users/tlaitinen/orgs","repos_url":"https://api.github.com/users/tlaitinen/repos","events_url":"https://api.github.com/users/tlaitinen/events{/privacy}","received_events_url":"https://api.github.com/users/tlaitinen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-02T07:58:20Z","updated_at":"2016-08-02T13:22:50Z","closed_at":null,"body":"The following code \r\n```javascript\r\nimport Rx from 'rxjs/Rx';\r\n\r\nconst s1 = Rx.Observable.interval(1000).take(3);\r\nconst s2 = Rx.Observable.interval(100).take(30);\r\nconst s3 = s1.withLatestFrom(s2, (v1,v2) => [v1,v2])\r\ns3.subscribe(function (x) { console.log(x) })\r\n```\r\noutputs \r\n```\r\n[ 0, 8 ]\r\n[ 1, 18 ]\r\n[ 2, 28 ]\r\n```\r\n\r\nAccording to FAQ, `withLatestFrom` can be expressed in xstream as follows:\r\n\r\n```javascript\r\nimport xs from 'xstream'\r\n\r\nconst s1 = xs.periodic(1000).take(3);\r\nconst s2 = xs.periodic(100).take(30);\r\nconst s3 = s1.map((v1) => s2.map((v2) => [v1,v2])).flatten(); \r\ns3.addListener({\r\n    next: x => console.log(x),\r\n    error: err => console.error(err),\r\n    complete: () => console.log('completed')\r\n})\r\n```\r\n\r\nHowever, it outputs 30 tuples instead of 3:\r\n```\r\n[ 0, 0 ]\r\n[ 0, 1 ]\r\n[ 0, 2 ]\r\n[ 0, 3 ]\r\n[ 0, 4 ]\r\n[ 0, 5 ]\r\n[ 0, 6 ]\r\n[ 0, 7 ]\r\n[ 0, 8 ]\r\n[ 1, 9 ]\r\n[ 1, 10 ]\r\n[ 1, 11 ]\r\n[ 1, 12 ]\r\n[ 1, 13 ]\r\n[ 1, 14 ]\r\n[ 1, 15 ]\r\n[ 1, 16 ]\r\n[ 1, 17 ]\r\n[ 1, 18 ]\r\n[ 2, 19 ]\r\n[ 2, 20 ]\r\n[ 2, 21 ]\r\n[ 2, 22 ]\r\n[ 2, 23 ]\r\n[ 2, 24 ]\r\n[ 2, 25 ]\r\n[ 2, 26 ]\r\n[ 2, 27 ]\r\n[ 2, 28 ]\r\n[ 2, 29 ]\r\ncompleted\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/staltz/xstream/issues/comments/236902223","html_url":"https://github.com/staltz/xstream/issues/97#issuecomment-236902223","issue_url":"https://api.github.com/repos/staltz/xstream/issues/97","id":236902223,"user":{"login":"Hypnosphi","id":6651625,"avatar_url":"https://avatars.githubusercontent.com/u/6651625?v=3","gravatar_id":"","url":"https://api.github.com/users/Hypnosphi","html_url":"https://github.com/Hypnosphi","followers_url":"https://api.github.com/users/Hypnosphi/followers","following_url":"https://api.github.com/users/Hypnosphi/following{/other_user}","gists_url":"https://api.github.com/users/Hypnosphi/gists{/gist_id}","starred_url":"https://api.github.com/users/Hypnosphi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hypnosphi/subscriptions","organizations_url":"https://api.github.com/users/Hypnosphi/orgs","repos_url":"https://api.github.com/users/Hypnosphi/repos","events_url":"https://api.github.com/users/Hypnosphi/events{/privacy}","received_events_url":"https://api.github.com/users/Hypnosphi/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T13:22:50Z","updated_at":"2016-08-02T13:22:50Z","body":"You switched over `s1` and `s2`"}}
{"actor":{"display_login":"Hypnosphi"}}