Skip to content

Instantly share code, notes, and snippets.

@Plnda
Last active September 6, 2020 18:42
Show Gist options
  • Save Plnda/05a7760933cc00dbdfa305735b1dfc57 to your computer and use it in GitHub Desktop.
Save Plnda/05a7760933cc00dbdfa305735b1dfc57 to your computer and use it in GitHub Desktop.
class WeatherViewModel: NetworkViewModel, ObservableObject {
typealias NetworkResource = Weather
var resource: Resource<NetworkResource> = .loading
var network: Network
var route: NetworkRoute = OpenWeatherRoute.weather
var bag: Set<AnyCancellable> = Set<AnyCancellable>()
init(with network: Network) {
self.network = network
}
}
@amitaman
Copy link

amitaman commented Sep 6, 2020

Hi Can you please explain this line typealias NetworkResource = Weather.
What is Weather here? Can you please upload the whole source code.

@Plnda
Copy link
Author

Plnda commented Sep 6, 2020

Hi Can you please explain this line typealias NetworkResource = Weather.
What is Weather here? Can you please upload the whole source code.

Weather in this case will be the decodable that is returned by the api, so this will be your model that will confirm to Codable / Decodable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment