square / square/workflow-swift
Consider something like LifecycleWorker
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 373
- Forks
- 46
- Avg merge
- 6h 38m
- Merged PRs (30d)
- 3
Description
Kotlin has LifecycleWorker that makes it easy to perform side-effects when the worker is started or stopped.
At the moment, this is essentially equivalent to doing the following in Swift:
func render(state: State, context: RenderContext<SomeWorkflow>) -> Rendering {
let onStart: () -> Void = …
let onEnd: () -> Void = …
context.runSideEffect(key: "lifecycle") { lifetime in
onStart()
lifetime.onEnded(onEnd)
}
…
}
We might consider making some convenience for this in Swift land. I’d hesitate tying it to Worker specifically since that lives in WorkflowReactiveSwift and this could be built more generally.
Open to suggestions on API shape
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked Kotlin LifecycleWorker.kt and the Swift render example using RenderContext.runSideEffect. Review how lifecycle effects are currently represented in Swift, then clarify the proposed API shape and its scope beyond Worker. Done means an agreed, documented convenience API with tests covering worker start and stop behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100