Skip to content

Consider something like LifecycleWorker #71

Open
@bencochran

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

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions