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
| public protocol AnalyticsReducer { | |
| associatedtype State | |
| associatedtype Action | |
| func analytics(before: State, after: State, action: Action) -> Effect<Action> | |
| } | |
| public struct _AnalyticsReducer<Base: Reducer, Analytics: AnalyticsReducer>: Reducer where Analytics.State == Base.State, Analytics.Action == Base.Action { | |
| @usableFromInline | |
| let base: Base |
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
| // Author: SwiftUI-Lab (swiftui-lab.com) | |
| // Description: Implementation of the showSizes() debugging modifier | |
| // blog article: https://swiftui-lab.com/layout-protocol-part-2 | |
| import SwiftUI | |
| struct MeasureExample: View { | |
| var body: some View { | |
| VStack { |
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/env sh | |
| # usage: sh ./generate-target-dependencies.sh | dot -Tsvg -o target-graph.svg | |
| packages=`swift package describe --type json` | |
| targets=`echo $packages | jq '.targets'` | |
| target_names=`echo $targets | jq -r '.[] | .name'` | |
| body="" | |
| template=`cat <<EOF | |
| digraph DependenciesGraph { |
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 Publisher { | |
| func asResult() -> AnyPublisher<Result<Output, Failure>, Never> { | |
| return map(Result.success) | |
| .catch { Just(Result.failure($0)) } | |
| .eraseToAnyPublisher() | |
| } | |
| } | |
| extension Publisher { | |
| func values<S, F: Error>() -> AnyPublisher<S, Never> where Output == Result<S, F>, Failure == Never { |
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
| public protocol DelegateProvider: AnyObject { | |
| static func notifyDelegate(_ instance: Self) | |
| } | |
| @propertyWrapper | |
| public struct Delegate<Value> { | |
| public var wrappedValue: Value | |
| public init(wrappedValue: Value) { | |
| self.wrappedValue = wrappedValue |
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 SwiftUI | |
| let isUITesting = /* your UI test detection here */ | |
| @main | |
| struct EntryPoint { | |
| static func main() { | |
| if isUITesting { | |
| UITestApp.main() |
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 UIKit | |
| #if canImport(SwiftUI) && DEBUG | |
| import SwiftUI | |
| struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable { | |
| let viewController: ViewController | |
| init(_ builder: @escaping () -> ViewController) { | |
| viewController = builder() | |
| } |
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 CryptoKit | |
| private protocol ByteCountable { | |
| static var byteCount: Int { get } | |
| } | |
| extension Insecure.MD5: ByteCountable { } | |
| extension Insecure.SHA1: ByteCountable { } |
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
| // | |
| // Combine+WithLatestFrom.swift | |
| // | |
| // Created by Shai Mishali on 29/08/2019. | |
| // Copyright © 2019 Shai Mishali. All rights reserved. | |
| // | |
| import Combine | |
| // MARK: - Operator methods |
NewerOlder