-
-
Save jasdev/432803d9002fec10d46272aad29e430a to your computer and use it in GitHub Desktop.
`DataLoadState` sketch.
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
enum DataLoadState<Value, Error: Swift.Error> { | |
case initial | |
case loading | |
case loaded(Value) | |
case error(Error) /// (1) A challenging exercise for the reader is to think through extending | |
/// this type to support paginated loadings. | |
var isLoading: Bool { /// (2) Again, taking cue from Point Free’s enumeration properties work. | |
/// This will be helpful when enabling and disabling buttons while a request is in-flight. | |
switch self { | |
case .loading: | |
return true | |
default: | |
return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment