ViewModel initialization
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
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