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

One-off events #80

Closed
ATizik opened this issue Sep 3, 2018 · 1 comment
Closed

One-off events #80

ATizik opened this issue Sep 3, 2018 · 1 comment

Comments

@ATizik
Copy link

ATizik commented Sep 3, 2018

In google samples certain events are propagated through SingleLiveEvent.

While this concept goes against MVI principle, it's needed in certain cases to greatly reduce boilerplate. For example, to show toast in current implementation I have to create a property inside my state, and inside View send an event back to ViewModel telling it that toast was shown.

Another similar solution can be used in every ViewModel to fire such one-off events.

Second example can be easily done through an additional subject inside MvRxStateStore and subscription inside withState

@gpeal
Copy link
Collaborator

gpeal commented Sep 3, 2018

@ATizik We use selectSubscribe for this. You will be delivered the initial value and any time it changes. We also have asyncSubscribe if it's an async prop to handle the unwrapped success or error values.

We use these to handle things like logging or showing toasts/snackbars.

If this isn't sufficient, can you reopen this with a specific use case?

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