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 StateMachine<State, Action> { | |
private(set) var state: State | |
private let transition: (State, Action) -> State? | |
init(startState: State, transition: @escaping (State, Action) -> State?) { | |
self.state = startState | |
self.transition = transition | |
} | |
mutating func apply(action: Action) -> Bool { |
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 PlaygroundSupport | |
import SwiftUI | |
struct DetailView: View { | |
@Environment(\.isPresented) var isPresented: Binding<Bool>? | |
@State var count = 0 | |
var body: some View { | |
VStack(spacing: 20) { | |
Text("Count: \(count)") |
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 UIKit | |
extension UIDevice { | |
enum ScreenModel { | |
case Classic | |
case Bigger | |
case BiggerPlus | |
} |
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 | |
typealias CancelableTask = (cancel: Bool) -> Void | |
func delay(time: NSTimeInterval, work: dispatch_block_t) -> CancelableTask? { | |
var finalTask: CancelableTask? | |
var cancelableTask: CancelableTask = { cancel in | |
if cancel { |