Closed jordond closed 5 years ago
Good catch! I actually haven't tested ViewEvent
together with EiffelViewModel
yet.
I'm currently thinking about making it possible to return null
in Update
to signal that the State
hasn't been modified but this may result in the same state being emitted multiple times if an update is signaled but copy
didn't actually change any values. (May happen occasionally, especially with LiveData
sources.)
As another solution we maybe could override equals
to include the handled
property of ViewEvent
but I'm not sure if that works.
I tried overriding the equals
but it was still failing for me. But I don't know enough about kotlin/java's equality checks to be confident that it doesn't work.
I'll continue brainstorming.
Ah, so If you make the TestViewEvent
a regular class
instead of a data class
, then the equals
from ViewEvent
will work.
Figured out the solution thanks to the kotlin docs on data classes.
I'll submit a PR soon.
I've run into an issue, and was curious about your thoughts on it.
What's happening is I have a button that dispatches an action, which updates the state with a
ViewEvent
for navigating to the next screen. Now if the user hits the back button, and tries to click the button again. The state won't update because it is blocked by the equality test. Because theViewEvents
are technically the same (even though the previous one washandled
).My use-case is for creating Navigation commands, but I have written a simple test that showcases a more basic example: