Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add primary associated types to SignalProducerConvertible & SignalProducerProtocol #855

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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