Created
February 12, 2021 05:20
-
-
Save raghunandankavi2010/3495b8cf78ab1cb0d7d2ce50115f09b3 to your computer and use it in GitHub Desktop.
Fragment A Observing Livedata
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
viewModel.vendor.observe(viewLifecycleOwner) { | |
it?.let { result -> | |
when (result) { | |
is Result.Success -> { | |
// do something on success | |
} | |
is Result.Error -> { | |
// print stack trace | |
} | |
is Result.Loading -> { | |
// dismiss loading | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment