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

Distinct ValueStream #689

Open
Conrad33 opened this issue Jul 25, 2022 · 5 comments
Open

Distinct ValueStream #689

Conrad33 opened this issue Jul 25, 2022 · 5 comments
Labels
waiting for response Waiting for follow up

Comments

@Conrad33
Copy link

I'm pretty new to this Dart stream stuff so maybe I'm missing something. But, is it possible to have a distinct ValueStream? The distinct method of the ValueStream class returns a regular Stream. I would like to have a distinct stream that I can synchronously grab the last item out of.

@hoc081098
Copy link
Collaborator

You can check my library: https://github.com/hoc081098/rxdart_ext#3-statestream

@hoc081098 hoc081098 added the waiting for response Waiting for follow up label Jul 27, 2022
@Conrad33
Copy link
Author

This seems like it could work, but why does StateSubject.stream return a regular Stream instead of a ValueStream? Is the only way to get the latest value synchronously to use the StateSubject object itself? This means I would have to update the type annotations of the code that uses this.

@hoc081098
Copy link
Collaborator

Thanks for pointing that, it seem to be a bug.

@Conrad33
Copy link
Author

Ok, that'll work then when that is fixed. On a side note, is there a reason this isn't available out of the box with regular Rx dart?

@hoc081098
Copy link
Collaborator

I encountered the same issue 2 years ago when using Flutter & StreamBuilder, I wrote and published distinct_value_connectable_stream.
Recently, I merged it to rxdart_ext and rename DistinctValue to State (inspired by Kotlinx Coroutines StateFlow).

On a side note, is there a reason this isn't available out of the box with regular Rx.

Because StateSubject is not a standard Subject in ReactiveX (includes: PublishSubject, BehaviorSubject, AsyncSubject, ReplaySubject).
So I decided to publish it in another package (rxdart_ext) :)).
I'm afraid including it in rxdart may confuse many users.

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

No branches or pull requests

2 participants