Last active
December 25, 2019 05:34
-
-
Save motorro/c6ddbc5254f7c3b85a0387f0acd8f7df to your computer and use it in GitHub Desktop.
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