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

Add stateless workflow convenience extensions to Swift #236

Closed
zach-klippenstein opened this issue Mar 29, 2019 · 2 comments
Closed

Add stateless workflow convenience extensions to Swift #236

zach-klippenstein opened this issue Mar 29, 2019 · 2 comments
Labels
platform inconsistency Issues or pull requests that address some inconsistency between Swift and Kotlin libraries. swift Affects the Swift library.
Milestone

Comments

@zach-klippenstein
Copy link
Collaborator

zach-klippenstein commented Mar 29, 2019

In Kotlin, we recently (#219, #213) refactored our Workflow type to be a general type, with two subtypes: StatefulWorkflow (was Workflow) and StatelessWorkflow (something we had before, but now more obviously a directly first-class citizen and sibling of StatefulWorkflow). So far the feedback from Android devs has been positive.

This is not a huge change, mostly just naming, so should we adopt it in Swift as well?

cc @davidapgar @timdonnelly @bencochran

@zach-klippenstein zach-klippenstein added this to the Cross-platform API Convergence milestone Mar 29, 2019
@zach-klippenstein zach-klippenstein removed this from the Cross-platform API Convergence milestone May 29, 2019
@JustinDSN JustinDSN added the swift Affects the Swift library. label Feb 27, 2020
@JustinDSN JustinDSN added this to the v1.0.0 milestone Mar 3, 2020
@rjrjr rjrjr added the platform inconsistency Issues or pull requests that address some inconsistency between Swift and Kotlin libraries. label Mar 4, 2020
@rjrjr
Copy link
Contributor

rjrjr commented Mar 26, 2020

Alternative for Swift:

When a Workflow’s state is Void, it’s typically meaningless to have a makeInitialState or workflowDidChange that’s different than the following:

// Helper for stateless workflows. (Use the consistent terminology.)
extension Workflow where State == Void {
    func makeInitialState() -> State {
        return ()
    }
    func workflowDidChange(from previousWorkflow: Self, state: inout State) {
    }
}

We should consider providing a default extension on Workflow when State == Void that implements those as such. If a workflow needs to, say, perform a side effect in either of those, they can still implement them and not use the default implementation.

@rjrjr
Copy link
Contributor

rjrjr commented Mar 26, 2020

Seems reasonable to diverge here, since Swift is nicer than Kotlin can be.

@rjrjr rjrjr changed the title Discuss: Adopt StatefulWorkflow / StatelessWorkflow terminology in Swift? Add stateless workflow convenience extensions to Swift Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform inconsistency Issues or pull requests that address some inconsistency between Swift and Kotlin libraries. swift Affects the Swift library.
Projects
None yet
Development

No branches or pull requests

3 participants