Skip to content

Instantly share code, notes, and snippets.

View jamiepinkham's full-sized avatar

Jamie Pinkham jamiepinkham

View GitHub Profile
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) }
struct IntBox: CustomDebugStringConvertible {
let int: Int
init(int: Int) {
self.int = int
}
var debugDescription: String {
return "Intbox: \(self.int)"
}
}
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
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.
//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
//
// ScrumData.swift
// Scrumdinger
//
// Created by Jamie Pinkham on 12/15/20.
//
import SwiftUI
import Combine