Skip to content

Commit

Permalink
Reimplement Zip to fix reference crash issue (#5)
Browse files Browse the repository at this point in the history
* Reimplement Zip to fix reference crash issue

* Add a test case for the documentation demo

* Fix wasm platform build issue
  • Loading branch information
Kyle-Ye committed Dec 20, 2023
1 parent 0cd6e02 commit 98fed00
Show file tree
Hide file tree
Showing 5 changed files with 664 additions and 617 deletions.
49 changes: 0 additions & 49 deletions RemainingCombineInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -901,52 +901,3 @@ extension Publishers.MergeMany : Equatable where Upstream : Equatable {
/// - rhs: Another value to compare.
public static func == (lhs: Publishers.MergeMany<Upstream>, rhs: Publishers.MergeMany<Upstream>) -> Bool
}

extension Publishers.Zip : Equatable where A : Equatable, B : Equatable {

/// Returns a Boolean value that indicates whether two publishers are equivalent.
///
/// - Parameters:
/// - lhs: A zip publisher to compare for equality.
/// - rhs: Another zip publisher to compare for equality.
/// - Returns: `true` if the corresponding upstream publishers of each zip publisher are equal, `false` otherwise.
public static func == (lhs: Publishers.Zip<A, B>, rhs: Publishers.Zip<A, B>) -> Bool
}

/// Returns a Boolean value that indicates whether two publishers are equivalent.
///
/// - Parameters:
/// - lhs: A zip publisher to compare for equality.
/// - rhs: Another zip publisher to compare for equality.
/// - Returns: `true` if the corresponding upstream publishers of each zip publisher are equal, `false` otherwise.
extension Publishers.Zip3 : Equatable where A : Equatable, B : Equatable, C : Equatable {

/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func == (lhs: Publishers.Zip3<A, B, C>, rhs: Publishers.Zip3<A, B, C>) -> Bool
}

/// Returns a Boolean value that indicates whether two publishers are equivalent.
///
/// - Parameters:
/// - lhs: A zip publisher to compare for equality.
/// - rhs: Another zip publisher to compare for equality.
/// - Returns: `true` if the corresponding upstream publishers of each zip publisher are equal, `false` otherwise.
extension Publishers.Zip4 : Equatable where A : Equatable, B : Equatable, C : Equatable, D : Equatable {

/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func == (lhs: Publishers.Zip4<A, B, C, D>, rhs: Publishers.Zip4<A, B, C, D>) -> Bool
}
6 changes: 6 additions & 0 deletions Sources/OpenCombine/Helpers/Violations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ extension Subscribers.Demand {
precondition(rawValue <= Subscribers.Demand.unlimited.rawValue)
precondition(rawValue > Subscribers.Demand.none.rawValue)
}

@_transparent
@inline(__always)
internal func assertValid() {
precondition(rawValue <= Subscribers.Demand.unlimited.rawValue)
}
}
9 changes: 9 additions & 0 deletions Sources/OpenCombine/Publishers/Publishers.Throttle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ extension Publishers {
self.latest = latest
}

/// Attaches the specified subscriber to this publisher.
///
/// Implementations of ``Publisher`` must implement this method.
///
/// The provided implementation of ``Publisher/subscribe(_:)-199o9``calls
/// this method.
///
/// - Parameter subscriber: The subscriber to attach to this ``Publisher``,
/// after which it can receive values.
// swiftlint:disable generic_type_name
public func receive<S>(subscriber: S)
where S: Subscriber, Upstream.Failure == S.Failure, Upstream.Output == S.Input
Expand Down
Loading

0 comments on commit 98fed00

Please sign in to comment.