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

Expose Publisher.asAnyWorkflow as public API #213

Merged
merged 1 commit into from
May 17, 2023

Conversation

amorde
Copy link
Member

@amorde amorde commented May 16, 2023

Without this API consuming a Publisher inside a workflow is only possible by either rendering it directly via .render(in:) or by first calling mapOutput:

somePublisher
    .mapOutput { $0 } // workaround for not being able to call `asAnyWorkflow()`
    .onOutput { state, output in
         // ...
    }.rendered(in: context)

@amorde amorde requested a review from a team as a code owner May 16, 2023 23:23
@@ -21,17 +21,17 @@ import Foundation
import Workflow

struct PublisherWorkflow<WorkflowPublisher: Publisher>: Workflow where WorkflowPublisher.Failure == Never {
public typealias Output = WorkflowPublisher.Output
public typealias State = Void
public typealias Rendering = Void
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing some cleanup while here - PublisherWorkflow isn't public so these don't need to be either

@mjohnson12
Copy link
Collaborator

Do we want to encourage using publishers directly in a workflow like this instead of using a worker?

@mjohnson12
Copy link
Collaborator

Do we want to encourage using publishers directly in a workflow like this instead of using a worker?

I guess we already indirectly exposed this with running and map output so I'm fine with it.

@amorde
Copy link
Member Author

amorde commented May 17, 2023

Do we want to encourage using publishers directly in a workflow like this instead of using a worker?

Is there a way to use PublisherWorkflow directly that I'm missing? Since its not public, the only way to use it is to call .render(in:) which skips other steps along the way

@mjohnson12
Copy link
Collaborator

Do we want to encourage using publishers directly in a workflow like this instead of using a worker?

Is there a way to use PublisherWorkflow directly that I'm missing? Since its not public, the only way to use it is to call .render(in:) which skips other steps along the way
You can do Publisher.running(in) which just calls asAnyWorkflow in the implementation so I'm fine with exposing asAnyWorkflow as public.

@amorde
Copy link
Member Author

amorde commented May 17, 2023

Oh I see - you mean manually defining your own worker like this.

The ReactiveSwift APIs allow you to use Signals directly similar to this PR, which is what prompted me to look for the same thing with Combine

@amorde amorde merged commit dd9042c into main May 17, 2023
@amorde amorde deleted the amorde/publisher-extension-accessibility branch May 17, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants