Skip to content

Instantly share code, notes, and snippets.

@jasdev

jasdev/data_load_state.swift Secret

Last active Apr 9, 2020
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