Open
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