Skip to content

Instantly share code, notes, and snippets.

@TungVuDuc2805
Last active May 5, 2020 02:59
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 TungVuDuc2805/456e09a289adee8db2b0e2fe267a7aea to your computer and use it in GitHub Desktop.
Save TungVuDuc2805/456e09a289adee8db2b0e2fe267a7aea to your computer and use it in GitHub Desktop.
class PostViewController {
private let loader: Loader
init(loader: Loader){
self.loader = loader
}
func loadFeed(){
loader.load()
}
}
var viewController: PostViewController?
Reachability.isWifi {
let wifiLoader = WifiLoader(url: URL(string: http://api.com/wifi/posts)!)
viewController = PostViewController(loader: wifiLoader)
} else if Reachability.isCelluar {
let cellularLoader = CellularLoader(url: URL(string: http://api.com/wifi/cellular)!)
viewController = PostViewController(loader: cellularLoader)
} else if Reachability.isOffline {
let localLoader = LocalLoader()
viewController = PostViewController(loader: localLoader)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment