Skip to content

Instantly share code, notes, and snippets.

@jasdev
Last active April 9, 2020 19:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
`DataLoadState` sketch.
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