This file contains 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
import Combine | |
import ReactiveSwift | |
import SwiftUI | |
class AnySubscription: Subscription { | |
private let cancelable: Cancellable | |
init(cancelable: Cancellable) { | |
self.cancelable = cancelable |
This file contains 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
/// `ObjectBinding` used as a way to create a `Binding` from a `BindableObject`. In this case the ViewModel | |
/// complies with `BindableObject` which is then translated into a `Binding` which is what `Toggle` is expecting | |
/// NOTE: Since it's a `DynamicViewProperty`, after its value is changed, the body will be updated. | |
class ViewModel: BindableObject { | |
let didChange = PassthroughSubject<ViewModel, Never>() | |
var isEnabled = false { | |
didSet { | |
didChange.send(self) |
This file contains 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
public extension UIViewController { | |
var modalFlow: Flow { | |
return ModalFlow(self) | |
} | |
var navigationFlow: Flow { | |
guard let navigationController = self.navigationController else { return modalFlow } | |
return NavigationFlow(navigationController) | |
} | |
} |
This file contains 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
import Foundation | |
precedencegroup PipePrecedence { | |
associativity: left | |
higherThan: AssignmentPrecedence | |
} | |
infix operator |> : PipePrecedence | |
public func |> <T, U>(x: T, f: (T) -> U) -> U { |
This file contains 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
import Foundation | |
enum Result<T> { | |
case success(T) | |
case failure(String) | |
func map<U>(_ f: (T) -> U) -> Result<U> { | |
switch self { | |
case .success(let x): return .success(x |> f) | |
case .failure(let e): return .failure(e) |
This file contains 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
import Foundation | |
"4 5 + 3 +" | |
func calculator(_ input: String) -> Double { | |
return input |> split |> reversePolishNotation | |
} | |
func reversePolishNotation(_ input: [String]) -> Double { | |
var stack: [Double] = [] |
This file contains 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 MyModelDTO { | |
let property1: Type1 | |
let property2: Type2 | |
} | |
extension MyModelDTO { | |
init(model: MyModel_CoreData) { | |
self.init(property1: model.property1, property2: model.property2) | |
} | |
} |
This file contains 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
class MyModel: NSObject { | |
var property1: Type1! | |
var property2: Type2! | |
} |
This file contains 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
Process: Xcode [3786] | |
Path: /Applications/Xcode.app/Contents/MacOS/Xcode | |
Identifier: com.apple.dt.Xcode | |
Version: 8.3 (12169) | |
Build Info: IDEFrameworks-12169000000000000~2 | |
App Item ID: 497799835 | |
App External ID: 821487965 | |
Code Type: X86-64 (Native) | |
Parent Process: ??? [1] | |
Responsible: Xcode [3786] |
This file contains 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
Process: Xcode [2788] | |
Path: /Applications/Xcode.app/Contents/MacOS/Xcode | |
Identifier: com.apple.dt.Xcode | |
Version: 8.3 (12169) | |
Build Info: IDEFrameworks-12169000000000000~2 | |
App Item ID: 497799835 | |
App External ID: 821487965 | |
Code Type: X86-64 (Native) | |
Parent Process: ??? [1] | |
Responsible: Xcode [2788] |