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
enum AsyncError: Error { | |
case finishedWithoutValue | |
} | |
extension AnyPublisher { | |
func async() async throws -> Output { | |
try await withCheckedThrowingContinuation { continuation in | |
var cancellable: AnyCancellable? | |
var finishedWithoutValue = true | |
cancellable = first() |
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 SwiftUI | |
public struct ChangeObserver<V: Equatable>: ViewModifier { | |
public init(newValue: V, action: @escaping (V) -> Void) { | |
self.newValue = newValue | |
self.newAction = action | |
} | |
private typealias Action = (V) -> Void |
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 Combine | |
import Combine | |
extension Sequence where Element == AnyCancellable { | |
/// Stores this type-erasing cancellable collection in the specified collection. | |
/// | |
/// - Parameter collection: The collection in which to store this ``AnyCancellable`` sequence. | |
func store<C>(in collection: inout C) where C: RangeReplaceableCollection, C.Element == Element { | |
forEach { $0.store(in: &collection) } |
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 Combine | |
import Foundation | |
extension NSObjectProtocol where Self: NSObject { | |
/// Assigns each unique element assigned to the key paths specified to the inverse object. | |
func bidirectionallyAssign<Value: Equatable, B: NSObject>( | |
from firstKeyPath: ReferenceWritableKeyPath<Self, Value>, | |
to secondKeyPath: ReferenceWritableKeyPath<B, Value>, | |
on otherObject: B | |
) -> [AnyCancellable] { |
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 Combine | |
import ObjectiveC.runtime | |
extension NSObject { | |
private enum AssociatedKeys { | |
static var CancellablesKey = "CancellablesKey" | |
} | |
/// A set that can be used to dispose of Combine cancellables. | |
public var cancellables: Set<AnyCancellable> { |
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 RangeReplaceableCollection { | |
static func += (collection: inout Self, element: Element) { | |
collection.append(element) | |
} | |
static func += (collection: inout Self, element: Element?) { | |
if let element = element { | |
collection.append(element) | |
} | |
} |
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 Vapor | |
extension EventLoopFuture { | |
/// When the current `EventLoopFuture<Value>` is fulfilled, run the provided callback, | |
/// which will provide a new `EventLoopFuture`. | |
/// | |
/// This allows you to dynamically dispatch new asynchronous tasks as phases in a | |
/// longer series of processing steps. Note that you can use the results of the | |
/// current `EventLoopFuture<Value>` when determining how to dispatch the next operation. | |
/// |
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 | |
@propertyWrapper | |
struct StringCoded<WrappedValue: LosslessStringConvertible>: Codable { | |
var wrappedValue: WrappedValue | |
init(wrappedValue: WrappedValue) { | |
self.wrappedValue = wrappedValue | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<array> | |
<dict> | |
<key>ApplicationIdentifier</key> | |
<string>com.sublimemerge</string> | |
<key>ApplicationName</key> | |
<string>Sublime Merge</string> | |
<key>DisplayName</key> |
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
// The MIT License (MIT) | |
// | |
// Copyright © 2018 Tony Arnold (@tonyarnold) | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
NewerOlder