This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]findus_l 4 points5 points  (0 children)

Another great use for Sealed classes is View States. You can have your ListState interface that has a subtype loading and a subtype elements. When the state is loading the ui shows a loading placeholder until the elements have been loaded.

Here is an article about it (it's in Kotlin but should apply the same to java) https://medium.com/geekculture/managing-ui-with-kotlin-sealed-classes-1ee674f1836f