From 9b4d72b6f049e45bb760bb1eaa9c4a1da0c40775 Mon Sep 17 00:00:00 2001 From: Oliver Foggin Date: Thu, 14 Dec 2023 18:29:51 +0000 Subject: [PATCH] Change parameter order --- README.md | 2 +- Sources/ComposableSubscriber/SubscriberReducer.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e25dcb6..067cfa5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Any dependency that returns an `AsyncStream` can be subscribed to in the followi Reduce { // your usual reducer here } -.subscribe(on: \.some.trigger.action, to: myDependency.strem, with: \.some.response.action) +.subscribe(to: myDependency.stream, on: \.some.trigger.action, with: \.some.response.action) ``` There is a requirement that the AsyncStream returns the same type as the response action takes. diff --git a/Sources/ComposableSubscriber/SubscriberReducer.swift b/Sources/ComposableSubscriber/SubscriberReducer.swift index 76ad546..e9eda5f 100644 --- a/Sources/ComposableSubscriber/SubscriberReducer.swift +++ b/Sources/ComposableSubscriber/SubscriberReducer.swift @@ -2,8 +2,8 @@ import ComposableArchitecture extension Reducer { public func subscribe( + to stream: @escaping () async -> AsyncStream, on triggerAction: CaseKeyPath, - to stream: @escaping () async throws -> AsyncStream, with responseAction: CaseKeyPath ) -> _SubscribeReducer { .init( @@ -23,7 +23,7 @@ public struct _SubscribeReducer: Reducer { let triggerAction: AnyCasePath @usableFromInline - let stream: () async throws -> AsyncStream + let stream: () async -> AsyncStream @usableFromInline let responseAction: AnyCasePath @@ -31,7 +31,7 @@ public struct _SubscribeReducer: Reducer { init( parent: Parent, on triggerAction: CaseKeyPath, - to stream: @escaping () async throws -> AsyncStream, + to stream: @escaping () async -> AsyncStream, with responseAction: CaseKeyPath ) { self.parent = parent @@ -50,7 +50,7 @@ public struct _SubscribeReducer: Reducer { return .merge( effects, .run { send in - for await value in try await stream() { + for await value in await stream() { await send(responseAction.embed(value)) } }