Skip to content

Then chaining base on condition #1153

@zorture

Description

@zorture

Is the below code possible? I am getting Error. Type '()' cannot conform to 'Thenable'; only struct/enum/class types can conform to protocols.
How do I achieve condition chaining inside then closure?

    firstly {
        Promise.value(1)
    }.then { _ in
        Promise.value(2)
    }.then { value in
        if value > 0 {
            Promise.value(3)
        } else {
            Promise.value(4)
        }
    }.done {
        print($0)  
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions