Skip to content

Instantly share code, notes, and snippets.

@motorro
Last active December 25, 2019 05:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
ViewModel initialization
abstract class BaseModel: ViewModel() {
var initialized: Boolean = false
private set
/**
* Called from activity's onCreate or onStart
*/
fun initialize() {
if (!initialized) {
doInitialize()
initialized = true
}
}
/**
* Internal initialization (if needed)
*/
protected open fun doInitialize() { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment