This file contains hidden or 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
var str = "Hello, playground" | |
enum Transformer<T> { | |
typealias Transform = NSData -> T?; | |
} | |
let data = str.dataUsingEncoding(NSUTF8StringEncoding)! | |
let transformer = Transformer<String>.Transform { data in return String(data: data, encoding: NSUTF8StringEncoding) } |
This file contains hidden or 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
struct IntBox: CustomDebugStringConvertible { | |
let int: Int | |
init(int: Int) { | |
self.int = int | |
} | |
var debugDescription: String { | |
return "Intbox: \(self.int)" | |
} | |
} |
This file contains hidden or 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
protocol Action { } | |
protocol State { | |
static var initial: Self { get } | |
} | |
typealias Reducer<S: State, A: Action> = (_ state: S, _ action: A) -> S | |
enum AnAction: Action { } | |
enum AState: State { | |
case none |
This file contains hidden or 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
enum MyError: Error { | |
case whoops | |
} | |
//Observable.create {} | |
let o = AnyPublisher<Int, MyError> { subscriber in | |
/* | |
onNext, but in combine you are returned a demand, | |
this is for controlling backpressure, which | |
doesn't exist in RxSwift. |
This file contains hidden or 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
//curries a 2 argument function | |
func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> (A) -> (B) -> C { | |
return { x -> (B) -> C in { y -> C in | |
f(x, y) | |
} | |
} | |
} | |
func add(x: Int, y: Int) -> Int { | |
return x + y |
This file contains hidden or 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
// | |
// ScrumData.swift | |
// Scrumdinger | |
// | |
// Created by Jamie Pinkham on 12/15/20. | |
// | |
import SwiftUI | |
import Combine |
OlderNewer