Skip to content

Instantly share code, notes, and snippets.

@Laimiux
Last active March 1, 2018 07:00
Show Gist options
  • Save Laimiux/d77a101fcdf47be34c5c12010f5ca1e3 to your computer and use it in GitHub Desktop.
Save Laimiux/d77a101fcdf47be34c5c12010f5ca1e3 to your computer and use it in GitHub Desktop.
sealed class CommentFormUserEvent {
data class TextChangedEvent(..): CommentFormUserEvent()
data class SubmitCommentRequestEvent(..): CommentFormUserEvent()
}
sealed class LoginFormUserEvent {
// We cannot use TextChangedEvent from CommentFormUserEvent
data class TextChangedEvent(..): LoginFormUserEvent()
data class LoginRequestEvent(..): LoginFormUserEvent()
}
// or we could do this, but we still end up with some duplicate logic
data class TextChangedEvent(val text: String, /* more properties */ )
sealed class CommentFormUserEvent {
data class CommentFormTextChangedEvent(val event: TextChangedEvent): CommentFormUserEvent()
data class SubmitCommentRequestEvent(..): CommentFormUserEvent()
}
sealed class LoginFormUserEvent {
// We cannot use TextChangedEvent from CommentFormUserEvent
data class LoginFormTextChangedEvent(val event: TextChangedEvent): LoginFormUserEvent()
data class LoginRequestEvent(..): LoginFormUserEvent()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment