Skip to content

Chaining a side effect function? #18

Description

@jaredramirez

Hey there, thanks for the great bindings!

Have you thought about adding a function like

let tap: (Promise.t<'val>, 'val => unit)

The purpose of such a function would be to chain a side effect based on the value of a promise. For example, setting some React state if a promise is successful or logging in between thens

Currently, this can be achieved with

let tap = (p, f) = Promise.thenResolve(p, v => {
    f(v)
    v
  })

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