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
//: Swift 3 State Store | |
import Foundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
protocol State { | |
var counter: Int { get } | |
} |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
enum PersonError: ErrorProtocol { | |
case doesNotExistInDataSource | |
case emailNotInPersonalData | |
} | |
struct Person { |
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
#!/usr/bin/swift | |
import Foundation | |
enum Device: String { | |
case phone | |
case tablet | |
var videoSize: Int { | |
switch self { |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
protocol Validator { | |
associatedtype T | |
func isValid(value: T) throws -> Bool | |
} |
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
extension CustomStringConvertible where Self: RawRepresentible, Self.RawValue == String { | |
var description: String { | |
return rawValue | |
} | |
} | |
extension CustomDebugStringConvertible where Self: RawRepresentible, Self.RawValue == String { | |
var debugDescription: String { | |
return "\(self)" | |
} |
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
#!/usr/bin/swift | |
import Foundation | |
// MARK:- Functions | |
func runShellCommand(cmd: String, env: [String : String]? = nil) -> (output: [String], error: [String], exitCode: Int32) { | |
var output : [String] = [] | |
var error : [String] = [] |
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 AlertsStatusUpdateAction: ActionCreatingAction { | |
case requestUpdate(AlertsService) | |
case updateFinishedWithAlerts([InAppAlert]) | |
case updateFinishedWithError(AlertsError) | |
func execute(state: AppState) -> AppState { | |
var mutableState = state | |
switch self { | |
case .requestUpdate(_): |
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
import Foundation | |
import XCPlayground | |
/*: | |
# Reflux | |
*/ | |
//: Interfaces | |
protocol State { | |
init() | |
var userState: UserState {get} |
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
//: Adventures in generics | |
import Foundation | |
protocol MyBaseProtocol { | |
func didSomething() | |
func didAnotherThing() | |
} | |
protocol MyDataProtocol : MyBaseProtocol { |
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
// Copy and Paste into a Swift playground | |
import Foundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
// Data Source (anything that implements subscripting for accessing data) | |
//protocol MapDataProviding { | |
// typealias Key: Hashable |
NewerOlder