Skip to content

Commit

Permalink
Merge pull request #855 from braker1nine/addPrimaryAssociatedTypes
Browse files Browse the repository at this point in the history
Add primary associated types to SignalProducerConvertible & SignalProducerProtocol
  • Loading branch information
RuiAAPeres authored Nov 12, 2022
2 parents a5690e6 + c5018ae commit ade1518
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# master
*Please add new entries at the top.*

1. Add primary associated types to SignalProducerConvertible & SignalProducerProtocol (#855, kudos to @braker1nine)
1. Refactor Github Actions to cover more swift versions (#858, kudos to @braker1nine)
1.Use `OSAllocatedUnfairLock` instead of `os_unfair_lock` on supported Apple platforms (#856, kudos to @mluisbrown)

Expand Down
28 changes: 28 additions & 0 deletions Sources/SignalProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,19 @@ extension SignalProducer where Error == Swift.Error {
}
}

#if swift(>=5.7)
/// Represents reactive primitives that can be represented by `SignalProducer`.
public protocol SignalProducerConvertible<Value, Error> {
/// The type of values being sent by `self`.
associatedtype Value

/// The type of error that can occur on `self`.
associatedtype Error: Swift.Error

/// The `SignalProducer` representation of `self`.
var producer: SignalProducer<Value, Error> { get }
}
#else
/// Represents reactive primitives that can be represented by `SignalProducer`.
public protocol SignalProducerConvertible {
/// The type of values being sent by `self`.
Expand All @@ -549,7 +562,21 @@ public protocol SignalProducerConvertible {
/// The `SignalProducer` representation of `self`.
var producer: SignalProducer<Value, Error> { get }
}
#endif

#if swift(>=5.7)
/// A protocol for constraining associated types to `SignalProducer`.
public protocol SignalProducerProtocol<Value, Error> {
/// The type of values being sent by `self`.
associatedtype Value

/// The type of error that can occur on `self`.
associatedtype Error: Swift.Error

/// The materialized `self`.
var producer: SignalProducer<Value, Error> { get }
}
#else
/// A protocol for constraining associated types to `SignalProducer`.
public protocol SignalProducerProtocol {
/// The type of values being sent by `self`.
Expand All @@ -561,6 +588,7 @@ public protocol SignalProducerProtocol {
/// The materialized `self`.
var producer: SignalProducer<Value, Error> { get }
}
#endif

extension SignalProducer: SignalProducerConvertible, SignalProducerProtocol {
public var producer: SignalProducer {
Expand Down

0 comments on commit ade1518

Please sign in to comment.