Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Known methods for coalescing / synchronizing value emission #568

Open
alexweej opened this issue Dec 7, 2021 · 2 comments
Open

Known methods for coalescing / synchronizing value emission #568

alexweej opened this issue Dec 7, 2021 · 2 comments

Comments

@alexweej
Copy link

alexweej commented Dec 7, 2021

This seems to be a more general Rx issue, but specifically we're looking for solutions in the RxCpp space.

If we have the following:

observable<int> a_obs = /*...*/;
observable<int> a_squared_obs = a_obs.map([](int const a) { return a * a; });
observable<int> x_obs =
    combine_latest(
        a_obs,
        a_squared_obs,
        [](int const a, int const a_squared) { return a + a_squared; }
    );

then we observe x_obs emitting nonsensical intermediate values when a_obs emits values. It is expected to always be a + a^2 but because each of the input observables updates independently, we get transitional values.

Our general problem extends beyond this synchronous value emission to ones using concat_map etc. with async processes and arbitrary streams of data for each input value, but we think this basic problem illustrates something we're missing either in our understanding of Rx or the feature set of RxCpp.

Please let us know if you have some ideas

Thanks!

@victimsnino
Copy link
Collaborator

Looks like you need zip operator instead?

@alexweej
Copy link
Author

alexweej commented Dec 7, 2021

Ah yes thanks, that does actually work well for this special case of having exactly 1 input for every 1 output. I think we have a problem that involves a more complicated case that I'll try to form an example of and get back to you tomorrow.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants