Skip to content

tryCatch

tryCatch<A>(f): TaskMaybe<A>

Defined in: Core/TaskMaybe.ts:66

Creates a TaskMaybe from a Promise-returning function. Returns Some if the promise resolves, None if it rejects. The factory optionally receives an AbortSignal forwarded from the call site.

A

(signal?) => Promise<A>

TaskMaybe<A>

const fetchUser = TaskMaybe.tryCatch((signal) =>
  fetch("/user/1", { signal }).then(r => r.json())
);