Skip to content

Instantly share code, notes, and snippets.

View crisrojas's full-sized avatar

Cristian Felipe Patiño Rojas crisrojas

View GitHub Profile
@swift2931
swift2931 / Bonfire.swift
Last active December 2, 2023 10:33
networking for SwiftUI
import SwiftUI
import Combine
protocol Service {
static var mods: [String: (inout URLRequest) -> Void] {get set}
var baseURL: String {get set}
func config(_ pat: String, _ mod: @escaping (inout URLRequest) -> Void)
func decorated(_ absURL: String, _ req: URLRequest) -> URLRequest
func match(_ pat: String, _ absURL: String) -> Bool
func makeRequest(_ relativeURL: String) -> URLRequest
@jakob
jakob / async-await-example.md
Last active October 20, 2022 08:56
Swift Async/Await: A thorough example

I love the async/await proposal, but some of the examples are too simplified. In this message I'd like to explore what a more thorough example could look like.

Let's start with this example from the proposal:

@IBAction func buttonDidClick(sender:AnyObject) {
  beginAsync {
    let image = await processImage()
    imageView.image = image
  }

}