/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
- World is a module
- World is aware of all modules.
- Modules aren't aware of World.
| Task { @MainActor in | |
| } |
| // let base = [1,2,4,6,5,8,6] | |
| // let filtered = base.takeUntil{ $0.isMultiple(of: 2) } // [2,4,6] | |
| // | |
| // let base = [2,4,6,5,8,6] | |
| // let filtered = base.takeUntil{ $0.isMultiple(of: 2) } // [2,4,6] | |
| // | |
| // It stops collecting when the predicate fails (5,8,6 are not evaluated) | |
| // | |
| // Idea by https://twitter.com/K0nserv | |
| // |
| public typealias CompletionHandler = Function<Void, Void> | |
| public typealias SideEffect<Input> = Function<Input, Void> | |
| public struct Function<Input, Output>: Identifiable { | |
| public let id: String | |
| internal let f: (Input) -> Output | |
| public init( | |
| id: String, |
| import ReactiveSwift | |
| import XCTest | |
| private let counterFailure: (Int, Int) -> String = { count, maxCount in | |
| return "Counter is currently at \(count) which higher than the max \(maxCount)" | |
| } | |
| private let timeoutFailure = "Expectation timeout" | |
| private let infoTemplate: (String, String, Int) -> String = { fileName, functionName, lineNumber in |
| /// This heavily based on the work done at RxGRDB | |
| import GRDB | |
| import ReactiveSwift | |
| extension DatabasePool: ReactiveExtensionsProvider {} | |
| extension DatabaseQueue: ReactiveExtensionsProvider {} | |
| extension ValueObservation: ReactiveExtensionsProvider {} | |
| extension DatabaseRegionObservation: ReactiveExtensionsProvider {} |
| import Foundation | |
| @propertyWrapper struct Notifier<Value> { | |
| private let identifier: String | |
| var wrappedValue: Value? { | |
| didSet { | |
| NotificationCenter.default.post(name: Notification.Name(identifier), object: wrappedValue) | |
| } | |
| } |
| public typealias CompletionHandler = Function<Void, Void> | |
| public typealias SideEffect<Input> = Function<Input, Void> | |
| public struct Function<Input, Output>: Identifiable { | |
| public let id: String | |
| internal let f: (Input) -> Output | |
| public init( | |
| id: String, |
/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
| import UIKit | |
| public extension UIColor { | |
| var components: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) { | |
| var red: CGFloat = 0 | |
| var green: CGFloat = 0 | |
| var blue: CGFloat = 0 | |
| var alpha: CGFloat = 0 |
| import UIKit | |
| // Based on https://www.stephanboyer.com/post/132/what-are-covariance-and-contravariance | |
| // > Denotes "a subtype of" | |
| // UIButton > UIView > UIResponder > NSObject | |
| // | |
| // e.g. `UIButton` is a subtype of `UIView` | |
| // | |
| // This means that any function that takes a `UIView`, can receive a `UIButton`: | |
| // |