diff --git a/Sources/ComposableSubscriber/SubscriberReducer.swift b/Sources/ComposableSubscriber/SubscriberReducer.swift index 01bc45f..fd10ab9 100644 --- a/Sources/ComposableSubscriber/SubscriberReducer.swift +++ b/Sources/ComposableSubscriber/SubscriberReducer.swift @@ -1,16 +1,19 @@ import ComposableArchitecture +import SwiftUI extension Reducer { public func subscribe( to stream: @escaping () async -> AsyncStream, on triggerAction: CaseKeyPath, - with responseAction: CaseKeyPath + with responseAction: CaseKeyPath, + animation: Animation? = nil ) -> _SubscribeReducer { .init( parent: self, on: triggerAction, to: stream, with: responseAction, + animation: animation, transform: { $0 } ) } @@ -19,6 +22,7 @@ extension Reducer { to stream: @escaping () async -> AsyncStream, on triggerAction: CaseKeyPath, with responseAction: CaseKeyPath, + animation: Animation? = nil, transform: @escaping (StreamElement) -> Value ) -> _SubscribeReducer { .init( @@ -26,6 +30,7 @@ extension Reducer { on: triggerAction, to: stream, with: responseAction, + animation: animation, transform: transform ) } @@ -47,17 +52,22 @@ public struct _SubscribeReducer Value + @usableFromInline + let animation: Animation? + init( parent: Parent, on triggerAction: CaseKeyPath, to stream: @escaping () async -> AsyncStream, with responseAction: CaseKeyPath, + animation: Animation?, transform: @escaping (StreamElement) -> Value ) { self.parent = parent self.triggerAction = AnyCasePath(triggerAction) self.stream = stream self.responseAction = AnyCasePath(responseAction) + self.animation = animation self.transform = transform } @@ -72,7 +82,7 @@ public struct _SubscribeReducer