Last active
July 11, 2021 11:52
-
-
Save catalinghita8/6a69c8328bd214c7f6fd2b9922e791d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun FoodCategoriesScreen( | |
state: FoodCategoriesContract.State, | |
effectFlow: Flow<FoodCategoriesContract.Effect>?, | |
onEventSent: (event: FoodCategoriesContract.Event) -> Unit, | |
onNavigationRequested: (navigationEffect: FoodCategoriesContract.Effect.Navigation) -> Unit | |
) { | |
// Listen for side effects from the VM | |
LaunchedEffect(LAUNCH_LISTEN_FOR_EFFECTS) { | |
effectFlow?.onEach { effect -> | |
when (effect) { | |
is FoodCategoriesContract.Effect.ToastDataWasLoaded -> { ... } | |
is FoodCategoriesContract.Effect.Navigation.ToCategoryDetails -> | |
onNavigationRequested(effect) | |
} | |
}?.collect() | |
} | |
Box { | |
FoodCategoriesList(foodItems = state.categories, onItemClicked = { itemId -> | |
onEventSent(FoodCategoriesContract.Event.CategorySelection(itemId)) | |
}) | |
if (state.isLoading) | |
LoadingBar() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment