Last active
August 30, 2016 11:23
-
-
Save yota345/1b4e9e8ef629b8f461a4c4e05a388e25 to your computer and use it in GitHub Desktop.
ViewState.swift (https://github.com/takuwan0405/RxSwiftSample)
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
/** | |
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