Skip to content

Ability to "fail to start" #36

@blaix

Description

@blaix

Currently if your application model depends on the result of a task that can fail, you need to keep a Maybe on the model, because you have to call Node.startProgram with an instance of your model no matter what. If there was a way to explicitly not start the program, you could avoid the Maybe and fail directly in init. For example:

getSecureContext : Task Never (Maybe Crypto.SecureContext)
getSecureContext =
    -- Turn fail-able task into one that always resolves. 
    ...

init env =
    Init.await getSecureContext <| \maybeSecureContext ->
        when maybeSecureContext is
            Nothing ->
                Node.failToStart "Failed to get secure context."
            Just secureContext ->
                Node.startProgram
                    { model =
                        { secureContext = secureContext -- don't need a Maybe
                        ...

Probably will want something similar for Browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions