Skip to content

Instantly share code, notes, and snippets.

@yota345
Last active August 30, 2016 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yota345/1b4e9e8ef629b8f461a4c4e05a388e25 to your computer and use it in GitHub Desktop.
Save yota345/1b4e9e8ef629b8f461a4c4e05a388e25 to your computer and use it in GitHub Desktop.
/**
Viewの状態を扱うenum
- .Working: 描画する要素があり、アプリが正常に動いている状態
- .Blank: 描画する要素がない状態
- .Requesting: 描画する要素を読み込んでいる状態
- .Error(ErrorType): エラーが起きている状態
*/
enum ViewState {
case Working
case Blank
case Requesting
case Error(ErrorType)
/**
APIを叩いても良い状態かを判定
*/
func fetchEnabled() -> Bool {
switch self {
case .Blank, .Working:
return true
default:
return false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment