question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dealing with one-time effects

See original GitHub issue

Here 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 Effects (single event type States)?

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:open
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Ethan1983commented, Jun 1, 2019

@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

1reaction
ScottCooper92commented, May 30, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found