Skip to content

Instantly share code, notes, and snippets.

@AniketSK
Created May 29, 2019 13:51
Show Gist options
  • Save AniketSK/cdfea90328ccb03de7bcdda3ebd73d8f to your computer and use it in GitHub Desktop.
Save AniketSK/cdfea90328ccb03de7bcdda3ebd73d8f to your computer and use it in GitHub Desktop.
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