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
final class Registry { | |
private var borrowings: [Borrowing] = [] | |
func copyWithAdded(_ borrowing: Borrowing) -> Registry { | |
let new = Registry() | |
new.borrowings = borrowings + [borrowing] | |
return new | |
} | |
func copyWithRemoved(_ borrowing: Borrowing) -> Registry { | |
let new = Registry() | |
new.borrowings = borrowings.filter { $0 !== borrowing } |
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
public protocol Borrowable { | |
var oid: ObjectIdentifier { get } | |
} | |
extension Shared: Borrowable { | |
public var oid: ObjectIdentifier { ObjectIdentifier(self) } | |
} |
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
p1: receive subscription: ([1, 2]) | |
p2: receive subscription: (["foo"]) | |
zip: receive subscription: (Zip) | |
zip: request unlimited | |
p1: request unlimited | |
p1: receive value: (1) | |
p1: receive value: (2) | |
p1: receive finished | |
p2: request unlimited | |
p2: receive value: (foo) |
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 | |
extension Publishers { | |
public struct WithLatestFrom<Upstream: Publisher, Other: Publisher>: | |
Publisher where Upstream.Failure == Other.Failure | |
{ | |
// MARK: - Types | |
public typealias Output = (Upstream.Output, Other.Output) | |
public typealias Failure = Upstream.Failure |
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 setupAdvPipeline() { | |
let searchStream = searchBar.searchTextField.textPublisher | |
.prepend(searchBar.text!) | |
.eraseToAnyPublisher() | |
let sparsedSearchStream = searchStream | |
.debounce(for: .seconds(0.3), scheduler: DispatchQueue.main) | |
.eraseToAnyPublisher() | |
let beginRefreshingStream = refreshControl |
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
var cancellables = Set<AnyCancellable>() | |
func setupPipelines() { | |
let searchStream = searchBar.searchTextField.textPublisher | |
.prepend(searchBar.text!) | |
.eraseToAnyPublisher() | |
let sparsedSearchStream = searchStream | |
.debounce(for: .seconds(0.3), scheduler: DispatchQueue.main) | |
.eraseToAnyPublisher() |
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 Publishers { | |
public struct WithLatestFrom<Upstream: Publisher, Other: Publisher>: Publisher where Upstream.Failure == Other.Failure { | |
// MARK: - Types | |
public typealias Output = (Upstream.Output, Other.Output) | |
public typealias Failure = Upstream.Failure |
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
var cancellables = Set<AnyCancellable>() | |
func setupStreams() { | |
let searchStream = searchBar.searchTextField.textPublisher | |
.prepend(searchBar.text!) | |
.eraseToAnyPublisher() | |
let sparsedSearchStream = searchStream | |
.debounce(for: .seconds(0.3), scheduler: DispatchQueue.main) | |
.eraseToAnyPublisher() |
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
var cancellables = Set<AnyCancellable>() | |
func setupStreams() { | |
let searchStream = searchBar.searchTextField.textStream | |
.prepend(searchBar.text!) | |
.eraseToAnyPublisher() | |
let sparsedSearchStream = searchStream | |
.debounce(for: .seconds(0.3), scheduler: DispatchQueue.main) | |
.eraseToAnyPublisher() |
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 Combine | |
extension UITextField { | |
var textStream: AnyPublisher<String?, Never> { | |
NotificationCenter.default | |
.publisher( | |
for: UITextField.textDidChangeNotification, | |
object: self) | |
.map(\.object) |