Skip to content

Add rejectIf #14

@dggluz

Description

@dggluz

Description

Handy to do:

findUser(userId)
    .chain(rejectIf(x => !x.length, new UserNotFoundError(userId))) 

Note: as the predicate is sync, it would be dangerous as you can pass a predicate to a Task<boolean, E> that will actually always be cast to true and the type system will not warn you. We should force the predicate - via typings - to be a sync predicate (a function to a boolean value).

We could also make another version for "tasked" predicates.

Metadata

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