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
/// source: http://www.objc.io/books/ | |
import Foundation | |
final public class Box<T> { | |
public let unbox: T | |
public init (_ value: T) { /// by adding '_' we can ignore the value name when we create a Box object (ex. this way we can just write something like let three = Box(3) | |
self.unbox = value | |
} | |
} |
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
let loremIpsum = ["Lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","Nunc","malesuada","vel","nisl","eget","sodales","Duis","sem","nulla","egestas","vel","neque","id","maximus","tempor","odio","Vestibulum","nisi","ipsum","porttitor","mattis","quam","sed","luctus","accumsan","velit","Curabitur","ornare","neque","eget","imperdiet","porttitor","nisi","odio","finibus","urna","quis","dignissim","mi","urna","vel","arcu","Lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","Mauris","vehicula","enim","eu","finibus","tempus","eros","tortor","interdum","risus","eu","condimentum","diam","dui","eu","lectus","Aenean","tincidunt","tincidunt","tellus","id","sollicitudin","Maecenas","ut","diam","fermentum","ante","scelerisque","dictum","Sed","finibus","lacus","in","dolor","euismod","vitae","sodales","nunc","varius","Nunc","vitae","dui","tincidunt","imperdiet","magna","sed","luctus","metus","Aenean","ullamcorper","dignissim","quam","vel","ornare","Suspendisse","potenti","Sed","lobortis", |
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
/* NOT QUITE FLEXIBLE | |
struct Field { | |
let id: String | |
let name: String | |
let value: String | |
let visible: 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 <Foundation/Foundation.h> | |
NS_ASSUME_NONNULL_BEGIN | |
@interface Optional : NSObject | |
+ (Optional*)with:(id _Nullable)value; | |
+ (Optional*)with:(id _Nullable)value as:(Class _Nonnull)valueClass; |
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 | |
public enum Persistence { | |
case Stop | |
case Continue | |
} | |
public final class Signal<Subtype> { | |
typealias Observation = Subtype -> Persistence |
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
/// MainPage initializer | |
init(feedbackModelController: ModelController<FeedbackModel>) { | |
super.init(nibName: nil, bundle: nil) | |
feedbackModelController.updateSignal.onReception § eachTime § updateViewsWithFeedbackModel | |
viewReadyEmitter.signal.onReception § eachTime § feedbackModelController.notify | |
} |
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
pageFactory.signalMakeMainPage | |
.flatMap { $0.signalLeaveFeedback } | |
.onReception § eachTime § inAnyCase § presentSelectionPage | |
pageFactory.signalMakeSelectionPage | |
.flatMap { $0.signalSelection } | |
.onReception § eachTime § inAnyCase § popTopPage |
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
func collectFeedbackModelChange() -> Signal<FeedbackModelChange> { | |
return pageFactory.signalMakeMainPage | |
.flatMap { $0.signalPolarizedChanged } | |
.map(FeedbackModel.transformWithPolarized) | |
+ pageFactory.signalMakeSelectionPage | |
.flatMap { $0.signalSelection } | |
.map(FeedbackModel.transformWithFeedback) | |
} |
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
feedbackModelController.deltaSignal | |
.filter { $0.feedback.rawValue < $1.feedback.rawValue} | |
.filter { $1.feedback == .Good || $1.feedback == .ReallyGood } | |
.onReception § eachTime § inAnyCase § showThankYouAlert |
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
/// source: https://broomburgo.github.io/fun-ios/post/lenses-and-prisms-in-swift-a-pragmatic-approach/ | |
protocol LensType { | |
associatedtype WholeType | |
associatedtype PartType | |
var get: (WholeType) -> PartType { get } | |
var set: (PartType,WholeType) -> WholeType { get } | |
init(get: @escaping (WholeType) -> PartType, set: @escaping (PartType,WholeType) -> WholeType) |
OlderNewer