{"repo":"leonard-palm/compose-state-events","free":true,"listed":false,"github":"https://github.com/leonard-palm/compose-state-events","clone":"git clone https://github.com/leonard-palm/compose-state-events.git","description":"A new way to implement One-Time-UI-Events (former SingleLiveEvent) in a Compose world.","language":"Kotlin","stars":188,"topics":["android","jetpack-compose","kotlin","kotlin-android","android-development","android-library","compose-ui","jetpack-android","state-management"],"license":"Apache-2.0","category":"mobile-apps","readme_excerpt":"Compose-State-Events A new way to implement One-Time-UI-Events (former SingleLiveEvent) in a Compose world. This library will help you to avoid implementing any antipatterns regarding One-Time-UI-Events as described by Manuel Vivo's article. See the samples below on how to effectively use StateEvent in your view's state and EventEffect in your composables. To get an in depth idea on how to migrate see this article from Yanneck Reiß. How to use Imagine a simple use-case where you need to fetch some list data from an API and display the result on the screen. View State Object Imagine we would like to show a green success snackbar or a red failure snackbar after the loading has finished. These two events would be represented with the two new fields downloadSucceededEvent and downloadFailedEvent in our view state object. Use the StateEventWithContent when you need to pass some data to the consumer (the composable). In the example above a StringRes with a fitting error description is passed. ViewModel To trigger an event without any data just use the triggered value, otherwise use the triggered(content: T) function. To consume an event without any data just use the consumed value, otherwise use the consumed() function. Composable The EventEffect is a LaunchedEffect that will be executed, when the event is in its triggered state. When the event action was executed the effect calls the passed onConsumed callback to force you to set the view state field to be consumed. Special Case: ","default_branch":null,"files":null,"tree":[],"storefront":"/r/leonard-palm","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/leonard-palm/compose-state-events/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}