{"action":"created","issue":{"url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/219","repository_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp","labels_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/219/comments","events_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/219/events","html_url":"https://github.com/Reactive-Extensions/RxCpp/issues/219","id":147853957,"number":219,"title":"zip(): different values from same source observable","user":{"login":"martinfinke","id":2064018,"avatar_url":"https://avatars.githubusercontent.com/u/2064018?v=3","gravatar_id":"","url":"https://api.github.com/users/martinfinke","html_url":"https://github.com/martinfinke","followers_url":"https://api.github.com/users/martinfinke/followers","following_url":"https://api.github.com/users/martinfinke/following{/other_user}","gists_url":"https://api.github.com/users/martinfinke/gists{/gist_id}","starred_url":"https://api.github.com/users/martinfinke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinfinke/subscriptions","organizations_url":"https://api.github.com/users/martinfinke/orgs","repos_url":"https://api.github.com/users/martinfinke/repos","events_url":"https://api.github.com/users/martinfinke/events{/privacy}","received_events_url":"https://api.github.com/users/martinfinke/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-12T19:44:15Z","updated_at":"2016-04-13T08:14:26Z","closed_at":"2016-04-12T20:27:16Z","body":"Please consider the following code:\r\n\r\n```cpp\r\nsubjects::behavior<int> b1(0);\r\nsubjects::behavior<double> b2(0.5);\r\nauto o1 = b1.get_observable();\r\nauto o2 = b2.get_observable();\r\n\r\no1.combine_latest(o2).zip(o1).subscribe([](const std::pair<std::pair<int, double>, int>& pair) {\r\n    std::cout << \"callback called with:\" << std::endl;\r\n    std::cout << \"{{\" << pair.first.first << \", \" << pair.first.second << \"}, \" << pair.second << \"}\" << std::endl;\r\n    assert(pair.first.first == pair.second);\r\n});\r\n\r\nstd::cout << \"b2 on_next()\" << std::endl;\r\nb2.get_subscriber().on_next(1.5);\r\nb2.get_subscriber().on_next(2.5);\r\nstd::cout << \"b1 on_next()\" << std::endl;\r\nb1.get_subscriber().on_next(1);\r\n\r\nb1.get_subscriber().on_completed();\r\nb2.get_subscriber().on_completed();\r\n```\r\n\r\nThis is the output:\r\n\r\n```\r\ncallback called with:\r\n{{0, 0.5}, 0}\r\nb2 on_next()\r\nb1 on_next()\r\ncallback called with:\r\n{{0, 1.5}, 1}\r\nAssertion failed: (pair.first.first == pair.second), function operator(), file main.cpp, line 16.\r\n```\r\n\r\nShouldn't `pair.first.first` and `pair.second` always be the same value in the callback, since both come from `o1`?\r\nIf I change `b1` to be a `subject`, the callback only gets called once (rightfully so), with the correct values.\r\nIf I take out the `assert` and call `b1`'s `on_next()` more times, the output is, to me, even more confusing:\r\n\r\n```\r\ncallback called with:\r\n{{0, 0.5}, 0}\r\nb2 on_next()\r\nb1 on_next()\r\ncallback called with:\r\n{{0, 1.5}, 1}\r\ncallback called with:\r\n{{0, 2.5}, 2}\r\ncallback called with:\r\n{{1, 2.5}, 3}\r\ncallback called with:\r\n{{2, 2.5}, 4}\r\ncallback called with:\r\n{{3, 2.5}, 5}\r\n```"},"comment":{"url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/comments/209296167","html_url":"https://github.com/Reactive-Extensions/RxCpp/issues/219#issuecomment-209296167","issue_url":"https://api.github.com/repos/Reactive-Extensions/RxCpp/issues/219","id":209296167,"user":{"login":"martinfinke","id":2064018,"avatar_url":"https://avatars.githubusercontent.com/u/2064018?v=3","gravatar_id":"","url":"https://api.github.com/users/martinfinke","html_url":"https://github.com/martinfinke","followers_url":"https://api.github.com/users/martinfinke/followers","following_url":"https://api.github.com/users/martinfinke/following{/other_user}","gists_url":"https://api.github.com/users/martinfinke/gists{/gist_id}","starred_url":"https://api.github.com/users/martinfinke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinfinke/subscriptions","organizations_url":"https://api.github.com/users/martinfinke/orgs","repos_url":"https://api.github.com/users/martinfinke/repos","events_url":"https://api.github.com/users/martinfinke/events{/privacy}","received_events_url":"https://api.github.com/users/martinfinke/received_events","type":"User","site_admin":false},"created_at":"2016-04-13T08:14:26Z","updated_at":"2016-04-13T08:14:26Z","body":"Wow, that was quick! Great, I'll try it later today."}}