/// | 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.
public protocol MapKey { | |
associatedtype Value | |
static var defaultValue: Value { get } | |
} | |
public struct Map<Base> { | |
typealias _Key = ObjectIdentifier | |
var _values: [_Key: Any] |
import UIKit | |
class ViewController: UIViewController { | |
let tableView: UITableView = { | |
let tv = UITableView(frame: .zero, style: .plain) | |
tv.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") | |
return tv | |
}() |
/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
extension Publisher { | |
public func on(_ f: @escaping (Self.Output) -> Void) -> AnyPublisher<Self.Output, Self.Failure> { | |
self.map { | |
f($0) | |
return $0 | |
}.eraseToAnyPublisher() | |
} | |
} |
import Foundation | |
// Diff objects for better test assertions. | |
// | |
// Implemented in a way that: | |
// 1. The compiler generates as much code as possible | |
// 2. You'll get a compiler error if you forget a property | |
// | |
// Nested support and collections left as an exercise for the reader. |
import SwiftUI | |
struct ScrollableView<Content: View>: UIViewControllerRepresentable { | |
// MARK: - Type | |
typealias UIViewControllerType = UIScrollViewController<Content> | |
// MARK: - Properties | |
var offset: Binding<CGPoint> | |
var animationDuration: TimeInterval |
#!/bin/sh | |
basename=`basename $0` | |
if [ -z "$*" ]; then | |
echo "usage: ${basename} <dot> [ -o | -r | <file> | - ]" | |
echo "" | |
echo "options:" | |
echo " -o open dot in window with keyboard focus" | |
echo " -r read contents of dot" |
import SwiftUI | |
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable { | |
// MARK: - Coordinator | |
final class Coordinator: NSObject, UIScrollViewDelegate { | |
// MARK: - Properties | |
private let scrollView: UIScrollView | |
var offset: Binding<CGPoint> |
import Cocoa | |
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
struct NSViewControllerPreview<ViewController: NSViewController>: NSViewControllerRepresentable { | |
let viewController: ViewController | |
init(_ builder: @escaping () -> ViewController) { | |
viewController = builder() |