Removed unneeded generic

This commit is contained in:
Oliver Foggin
2023-12-14 21:16:55 +00:00
parent 1ee469ff4f
commit 7a491bbe05

View File

@@ -2,20 +2,6 @@ import ComposableArchitecture
import SwiftUI import SwiftUI
extension Reducer { extension Reducer {
public func subscribe<TriggerAction, StreamElement>(
to stream: @escaping @Sendable () async -> AsyncStream<StreamElement>,
on triggerAction: CaseKeyPath<Action, TriggerAction>,
operation: @escaping @Sendable (_ send: Send<Action>, StreamElement) async throws -> Void
) -> _SubscribeReducer<Self, TriggerAction, StreamElement, StreamElement> {
.init(
parent: self,
on: triggerAction,
to: stream,
with: .operation(f: operation),
transform: { $0 }
)
}
public func subscribe<TriggerAction, StreamElement>( public func subscribe<TriggerAction, StreamElement>(
to stream: @escaping @Sendable () async -> AsyncStream<StreamElement>, to stream: @escaping @Sendable () async -> AsyncStream<StreamElement>,
on triggerAction: CaseKeyPath<Action, TriggerAction>, on triggerAction: CaseKeyPath<Action, TriggerAction>,
@@ -46,10 +32,24 @@ extension Reducer {
transform: transform transform: transform
) )
} }
public func subscribe<TriggerAction, StreamElement>(
to stream: @escaping @Sendable () async -> AsyncStream<StreamElement>,
on triggerAction: CaseKeyPath<Action, TriggerAction>,
operation: @escaping @Sendable (_ send: Send<Action>, StreamElement) async throws -> Void
) -> _SubscribeReducer<Self, TriggerAction, StreamElement, StreamElement> {
.init(
parent: self,
on: triggerAction,
to: stream,
with: .operation(f: operation),
transform: { $0 }
)
}
} }
@usableFromInline @usableFromInline
enum Operation<Action, Value, StreamElement> { enum Operation<Action, Value> {
case action(action: AnyCasePath<Action, Value>, animation: Animation?) case action(action: AnyCasePath<Action, Value>, animation: Animation?)
case operation(f: (_ send: Send<Action>, Value) async throws -> Void) case operation(f: (_ send: Send<Action>, Value) async throws -> Void)
} }
@@ -65,7 +65,7 @@ public struct _SubscribeReducer<Parent: Reducer, TriggerAction, StreamElement, V
let stream: () async -> AsyncStream<StreamElement> let stream: () async -> AsyncStream<StreamElement>
@usableFromInline @usableFromInline
let operation: Operation<Parent.Action, Value, StreamElement> let operation: Operation<Parent.Action, Value>
@usableFromInline @usableFromInline
let transform: (StreamElement) -> Value let transform: (StreamElement) -> Value
@@ -74,7 +74,7 @@ public struct _SubscribeReducer<Parent: Reducer, TriggerAction, StreamElement, V
parent: Parent, parent: Parent,
on triggerAction: CaseKeyPath<Parent.Action, TriggerAction>, on triggerAction: CaseKeyPath<Parent.Action, TriggerAction>,
to stream: @escaping @Sendable () async -> AsyncStream<StreamElement>, to stream: @escaping @Sendable () async -> AsyncStream<StreamElement>,
with operation: Operation<Parent.Action, Value, StreamElement>, with operation: Operation<Parent.Action, Value>,
transform: @escaping @Sendable (StreamElement) -> Value transform: @escaping @Sendable (StreamElement) -> Value
) { ) {
self.parent = parent self.parent = parent