Created
September 18, 2019 01:44
-
-
Save ininmm/c7ad9a8aa41b244ae76e1dd093804d81 to your computer and use it in GitHub Desktop.
使用 Lambda 的 ViewModel
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
fun getTokenAsync(action: (Token) -> Unit) { | |
...... | |
} | |
fun verifyAsync( | |
token: Token, | |
userName: String, | |
action: (Boolean) -> Unit | |
) { | |
...... | |
} | |
fun requestAndSaveUserDataAsync( | |
userName: String, | |
result: (Result) -> Unit | |
) { | |
...... | |
} | |
...... | |
fun login(userName: String) { | |
getTokenAsync { token -> | |
verifyAsync(token, userName) { verifyResult -> | |
requestAndSaveUserDataAsync(userName) { result -> | |
showLoginSuccess("Success") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment