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
    
  
  
    
  | // From /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface | |
| // swift-interface-format-version: 1.0 | |
| // swift-compiler-version: Apple Swift version 5.3 (swiftlang-1200.2.26.4 clang-1200.0.29.4) | |
| // swift-module-flags: -target x86_64-apple-ios14.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-library-evolution -module-name Combine | |
| import Darwin | |
| import Swift | |
| @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
| extension Publisher { | |
| public func multicast<S>(_ createSubject: @escaping () -> S) -> Combine.Publishers.Multicast<Self, S> where S : Combine.Subject, Self.Failure == S.Failure, Self.Output == S.Output | |
| public func multicast<S>(subject: S) -> Combine.Publishers.Multicast<Self, S> where S : Combine.Subject, Self.Failure == S.Failure, Self.Output == S.Output | 
  
    
      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 Combine | |
| import CoreFoundation | |
| import CoreGraphics | |
| import CoreText | |
| import Darwin | |
| import Foundation | |
| import SwiftUI | |
| import UIKit | |
| import os.log | |
| import os | 
  
    
      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 Darwin | |
| /// A type-erasing cancellable object that executes a provided closure when canceled. | |
| /// | |
| /// Subscriber implementations can use this type to provide a “cancellation token” that makes it possible for a caller to cancel a publisher, but not to use the ``Subscription`` object to request items. | |
| /// | |
| /// An ``AnyCancellable`` instance automatically calls ``Cancellable/cancel()`` when deinitialized. | |
| @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
| final public class AnyCancellable : Cancellable, Hashable { | 
  
    
      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 View { | |
| func iff(_ condition: Bool, _ modifier: (Self) -> AnyView) -> AnyView { | |
| if condition { | |
| return modifier(self).eraseToAnyView() | |
| } | |
| return eraseToAnyView() | |
| } | |
| func some<Value>(_ optional: Value?, modifier: (Value, Self) -> AnyView) -> some View { | |
| guard let value = optional else { | 
  
    
      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
    
  
  
    
  | - (UIImage *)dynamicImage | |
| { | |
| UITraitCollection *const baseTraitCollection = /* an existing trait collection */; | |
| UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]]; | |
| UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]; | |
| UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]]; | |
| __block UIImage *lightImage; | |
| [lightTraitCollection performAsCurrentTraitCollection:^{ | |
| lightImage = /* draw image */; | 
  
    
      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
    
  
  
    
  | /*: | |
| This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI | |
| The only purpose of this code is to implement those wrappers myself | |
| just to understand how they work internally and why they are needed, | |
| ⚠️ This is not supposed to be a reference implementation nor cover all | |
| subtleties of the real Binding and State types. | |
| The only purpose of this playground is to show how re-implementing | |
| them myself has helped me understand the whole thing better | 
  
    
      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
    
  
  
    
  | final class Loader: BindableObject { | |
| let didChange = PassthroughSubject<Data?, Never>() | |
| var task: URLSessionDataTask! | |
| var data: Data? = nil { | |
| didSet { | |
| didChange.send(data) | |
| } | |
| } | |
| init(_ url: URL) { | 
  
    
      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
    
  
  
    
  | // | |
| // ContentView.swift | |
| // TestingMoreSwiftUI | |
| // | |
| // Created by Chris Eidhof on 04.06.19. | |
| // Copyright © 2019 Chris Eidhof. All rights reserved. | |
| // | |
| import SwiftUI | |
| import Combine | 
  
    
      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
    
  
  
    
  | struct Foo: Codable { | |
| let type: String | |
| let value: String | |
| } | |
| struct Bar: Codable { | |
| let type: String | |
| let value: Int | |
| } | |
| protocol Item { } | 
  
    
      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
    
  
  
    
  | // Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
| // Remove any duplicates from an array of primitives. | |
| const unique = [...new Set(arr)] | |
| // Sleep in async functions. Use: await sleep(2000). | |
| const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
| // or | |
| const sleep = util.promisify(setTimeout); |