Skip to content

Instantly share code, notes, and snippets.

@yveskalume
Created September 15, 2021 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yveskalume/cfee71c0706f3eaca7b0e638eeea7463 to your computer and use it in GitHub Desktop.
Save yveskalume/cfee71c0706f3eaca7b0e638eeea7463 to your computer and use it in GitHub Desktop.
override fun invalidate(): Unit = withState(postViewModel) {
binding.progess.isVisible = it.post is Loading
when (it.post) {
is Success -> {
binding.progess.visibility = View.GONE
adapter.submitList(it.post.invoke())
}
is Fail -> {
Toast.makeText( requireContext(), "An error occured", Toast.LENGTH_SHORT).show()
Log.e("message", it.post.error.localizedMessage)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment