Created
May 29, 2019 13:51
-
-
Save AniketSK/cdfea90328ccb03de7bcdda3ebd73d8f to your computer and use it in GitHub Desktop.
Taken from https://github.com/kanawish/android-mvi-sample/tree/lesson/testing-state-machines while learning MVI
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
companion object { | |
/** | |
* Creates an intent for the TaskEditor state machine. | |
* | |
* Utility function to cut down on boilerplate. | |
*/ | |
inline fun <reified S : TaskEditorState> editorIntent( | |
crossinline block: S.() -> TaskEditorState | |
): Intent<TaskEditorState> { | |
return intent { | |
(this as? S)?.block() | |
?: throw IllegalStateException("editorIntent encountered an inconsistent State. [Looking for ${S::class.java} but was ${this.javaClass}]") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment