Skip to content

Instantly share code, notes, and snippets.

View Plnda's full-sized avatar

Jason Meulenhoff Plnda

View GitHub Profile
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Weapon))]
public class Controller : MonoBehaviour
{
// Start is called before the first frame update
@Plnda
Plnda / file.swift
Last active January 20, 2020 10:30
Group {
VStack(alignment: .center) {
ZStack {
Circle()
.fill(AssetColors.color(.onBlueColor))
.frame(width: scale - degreeLength, height: scale - degreeLength, alignment: .center)
Circle()
.stroke(AssetColors.color(.secondaryTextColor), style: StrokeStyle(lineWidth: degreeLength, lineCap: .butt, lineJoin: .miter, dash: [4]))
.frame(width: scale, height: scale, alignment: .center)
Circle()
import Foundation
enum NetworkEnvironment: String {
case openWeather = "https://api.openweathermap.org/data/2.5"
}
import Foundation
protocol NetworkRoute {
var path: String { get }
var method: NetworkMethod { get }
var headers: [String: String]? { get }
}
extension NetworkRoute {
import Foundation
enum NetworkMethod: String {
case get
case post
case put
case patch
case delete
}
import Foundation
import Combine
protocol Network {
var decoder: JSONDecoder { get set }
var enviroment: NetworkEnviroment { get set }
}
extension Network {
struct OpenWeatherNetwork: Network {
var decoder: JSONDecoder = JSONDecoder()
var environment: NetworkEnvironment = .openWeather
}
import Foundation
enum OpenWeatherRoute {
case weather
}
extension OpenWeatherRoute: NetworkRoute {
var path: String {
switch self {
import Foundation
import Combine
protocol NetworkViewModel: ObservableObject {
associatedtype NetworkResource: Decodable
var objectWillChange: ObservableObjectPublisher { get }
var resource: Resource<NetworkResource> { get set }
var network: Network { get set }
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) {