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 | |
import Foundation | |
// NOTE: This playground shows how to use Swift's AttributedString with Markdown. | |
// | |
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks> | |
// MARK: - Helpful Links | |
// NOTE: The following links helped me figure this stuff out. |
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 | |
import os.log | |
class URLCacheTest { | |
let logger = Logger(subsystem: "URLCacheTest", category: "main") | |
// HTTP HEADERS: | |
// Date: Wed, 04 Nov 2020 11:13:24 GMT | |
// Server: Apache | |
// Strict-Transport-Security: max-age=63072000; includeSubdomains; preload |
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
diff --git a/0084-testable-state-management-ergonomics/PrimeTime/ComposableArchitecture/ComposableArchitecture.swift b/0084-testable-state-management-ergonomics/PrimeTime/ComposableArchitecture/ComposableArchitecture.swift | |
index db4ab12..ab96c5f 100644 | |
--- a/0084-testable-state-management-ergonomics/PrimeTime/ComposableArchitecture/ComposableArchitecture.swift | |
+++ b/0084-testable-state-management-ergonomics/PrimeTime/ComposableArchitecture/ComposableArchitecture.swift | |
@@ -128,3 +128,24 @@ public func logging<Value, Action>( | |
}] + effects | |
} | |
} | |
+ | |
+ |
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 | |
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable { | |
let viewController: ViewController | |
init(_ builder: @escaping () -> ViewController) { | |
viewController = builder() | |
} |
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
extension Store { | |
public func send<LocalValue>( | |
_ action: @escaping (LocalValue) -> Action, | |
binding keyPath: KeyPath<Value, LocalValue> | |
) -> Binding<LocalValue> { | |
Binding( | |
get: { self.value[keyPath: keyPath] }, | |
set: { self.send(action($0)) } | |
) | |
} |
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
extension View { | |
func presentation(_ alert: Alert?) -> some View { | |
guard let alert = alert else { return AnyView(self) } | |
let binding = Binding<Bool>.constant(true) | |
return AnyView(self.presentation(binding) { alert }) | |
} | |
} |
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 debounce<T>(delay: TimeInterval, function: @escaping (T) -> Void, complete: @escaping () -> Void = { }) -> (T) -> Void { | |
let queue = DispatchQueue(label: "Debouncer") | |
var current: DispatchWorkItem? | |
return { input in | |
current?.cancel() | |
let new = DispatchWorkItem { | |
function(input) | |
complete() | |
} |
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 | |
/// A sequence whose elements are emitted in batches of the specified size | |
struct BatchedSequence<Base: Sequence>: Sequence { | |
private let size: Int | |
private let base: Base | |
init(base: Base, size: Int) { | |
self.size = size | |
self.base = base |
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 Notification<T> { | |
let name: NSNotification.Name | |
} | |
private let notificationData = "_notificationData" | |
extension NotificationCenter { | |
func post<T>(_ notification: Notification<T>, object: Any? = nil, data: T) { | |
post(name: notification.name, object: object, userInfo: [notificationData: data]) | |
} |
NewerOlder