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

Implementating an EventFlow now #2005

Closed
ZakTaccardi opened this issue May 8, 2020 · 4 comments
Closed

Implementating an EventFlow now #2005

ZakTaccardi opened this issue May 8, 2020 · 4 comments

Comments

@ZakTaccardi
Copy link

Looking at the release notes for 1.3.6

For events you should continue to either use BroadcastChannel(1), if you put events into the StateFlow, protect them from double-processing with flags.

I see two preferred ways to publish events as a Flow<Event> to guarantee they are consumed.

  1. Guaranteed delivery to a single subscriber - no multiple subscribers
  2. Guaranteed delivery to at least single subscriber, but multiple subscribers can receive events

My understanding of BroadcastChannel<Event>(1) is that it will drop events if there are no subscribers at the time, which does not make it very useful in my opinion.

@OrhanTozan
Copy link

OrhanTozan commented May 9, 2020

We are using Channel<Event>() for events. Is there any reason why one would use BroadcastChannel(1) over that?

Edit: Followed by channel.receiveAsFlow().

@elizarov
Copy link
Contributor

elizarov commented May 9, 2020

We are using Channel<Event>() for events. Is there any reason why one would use BroadcastChannel(1) over that?

@NahroTo It works fine, too.

@elizarov
Copy link
Contributor

elizarov commented May 9, 2020

My understanding of BroadcastChannel<Event>(1) is that it will drop events if there are no subscribers at the time, which does not make it very useful in my opinion.

@ZakTaccardi It depends on your use-case. With mouse-clicks, etc, you usually want to start listening to them only from the moment of subscription and onwards.

@elizarov
Copy link
Contributor

I'm closing this question. See also #2034 for a configurable SharedFlow primitive that covers a wide-range of event-distribution use-cases.

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

No branches or pull requests

3 participants