Dealing with one-time effects
See original GitHub issueHere is a scenario:
Your screen supports rotation. A particular Action
can generate an error which should display a Snackbar
.
How do we deal with it? Emit the error State
initially but not after rotation to avoid displaying the Snackbar
twice? What should the State
be after rotation then?
Should we introduce a concept of Effect
s (single event type State
s)?
In the spirit of Roxie’s lightweight way of doing things, it would be ideal to solve this with minimal code needed by the consumer apps.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Understanding the Impact of Trauma - NCBI
Trauma, including one-time, multiple, or long-lasting repetitive events, affects everyone differently. Some individuals may clearly display criteria ...
Read more >What Is a One-Time Item?
A one-time item is a gain, loss or expense on the income statement that is nonrecurring in nature and therefore not considered part...
Read more >Caffeine Overdose: Symptoms, Side Effects, and Treatment
Caffeine overdose can also worsen preexisting health conditions, such as anxiety.
Read more >Healthy Vs. Unhealthy Coping Mechanisms
Learn about common unhealthy coping skills we think are helpful and discover other healthier solutions that might prove more beneficial.
Read more >Side-effects in Compose
A side-effect is a change to the state of the app that happens outside the scope of a composable function. Due to composables'...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Glurt Just FYI. Trying to relay navigation update as event/effect (SingleLiveEvent) fails in an edge case with lifecycle and fragment transactions.
https://github.com/kaushikgopal/movies-usf/issues/19
I’ve just run into the same problem when trying to use the Navigation Component. I was thinking along the same lines as you by introducing another emitter using SingleLiveEvent.
That way you have States which change the state of the UI and you have Events/Effects that trigger something like navigation, snackbars, dialogs, permission requests etc
The question is how to split Changes into either States or Events, an example would be the user pressing a “locate me” button, the Action triggers a Change that updates the State to show a progress spinner, whilst the Event needs to trigger a permission request. It gets trickier when we need to do something based on the results of the Event, did they accept it or did they reject it etc