From a8b4c2f7f0398d6846396bf1a347b84cfe927d54 Mon Sep 17 00:00:00 2001 From: Oliver Foggin Date: Thu, 14 Dec 2023 19:09:13 +0000 Subject: [PATCH] Add animation --- .../ComposableSubscriber/SubscriberReducer.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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