Created
September 1, 2021 05:31
-
-
Save mattmook/f3e2be9deba94c48cd98a71a54b8fcde to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class PostListViewModel( | |
private val postRepository: PostRepository, | |
) : ViewModel(), ContainerHost<PostListState, NavigationEvent> { | |
override val container = viewModelScope.container<PostListState, NavigationEvent>( | |
initialState = PostListState() | |
) { | |
loadOverviews() | |
} | |
private fun loadOverviews() = intent { | |
val overviews = postRepository.getOverviews() | |
reduce { | |
state.copy(overviews = overviews) | |
} | |
} | |
fun onPostClicked(post: PostOverview) = intent { | |
postSideEffect(OpenPostNavigationEvent(post)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment