Skip to content

Op

Op: object

Defined in: Core/Op.ts:63

all: <E, A>(invocations) => Deferred<readonly Outcome<E, A>[]>

E

A

readonly Deferred<Outcome<E, A>>[]

Deferred<readonly Outcome<E, A>[]>

chain: <E, A, B>(f) => (outcome) => Outcome<E, B>

E

A

B

(a) => Outcome<E, B>

(outcome) => Outcome<E, B>

create: <E, A, I>(factory, onError) => Op<I, E, A>

E

A

I = void

(signal) => (input) => Promise<A>

(e) => E

Op<I, E, A>

fold: <E, A, B>(onErr, onNil, onOk) => (outcome) => B

E

A

B

(e) => B

() => B

(a) => B

(outcome) => B

getOrElse: <E, A, B>(defaultValue) => (outcome) => A | B

E

A

B

() => B

(outcome) => A | B

interpret: <I, E, A, O>(op, options) => InterpretResult<I, E, A, O> = interpretFn

I

E

A

O extends AllInterpretOptions<I, E>

Op<I, E, A>

O

InterpretResult<I, E, A, O>

is: object

err: <E, A>(state) => state is Err<E> = isErr

Type guard that checks if an Op state or outcome is Err.

E

A

State<E, A>

state is Err<E>

if (Op.is.err(outcome)) {
  showError(outcome.error);
}

idle: <E, A>(state) => state is Idle = isIdle

Type guard that checks if an Op state is Idle.

E

A

State<E, A>

state is Idle

if (Op.is.idle(manager.state)) {
  console.log("Ready to execute");
}

nil: <E, A>(state) => state is Nil = isNil

Type guard that checks if an Op state or outcome is Nil.

E

A

State<E, A>

state is Nil

if (Op.is.nil(outcome)) {
  console.log("Skipped due to:", outcome.reason);
}

ok: <E, A>(state) => state is Ok<A> = isOk

Type guard that checks if an Op state or outcome is Ok.

E

A

State<E, A>

state is Ok<A>

if (Op.is.ok(outcome)) {
  render(outcome.value);
}

pending: <E, A>(state) => state is Pending = isPending

Type guard that checks if an Op state is Pending (actively executing).

E

A

State<E, A>

state is Pending

if (Op.is.pending(manager.state)) {
  showSpinner();
}

queued: <E, A>(state) => state is Queued = isQueued

Type guard that checks if an Op state is Queued (waiting in a concurrency queue).

E

A

State<E, A>

state is Queued

if (Op.is.queued(manager.state)) {
  console.log("Position in queue:", manager.state.position);
}

retrying: <E, A>(state) => state is Retrying<E> = isRetrying

Type guard that checks if an Op state is Retrying after a failure.

E

A

State<E, A>

state is Retrying<E>

if (Op.is.retrying(manager.state)) {
  console.log("Retry attempt:", manager.state.attempt);
}

lift: <I, A>(f) => Op<I, unknown, A>

I

A

(input, signal) => Promise<A>

Op<I, unknown, A>

make: object

err: <E>(error) => Err<E> = makeErr

Creates an Err outcome with the given error.

E

E

Err<E>

Op.make.err("Something went wrong"); // { kind: "OpErr", error: "Something went wrong" }

nil: (reason) => Nil = makeNil

Creates a Nil outcome with the given cancellation/drop reason.

NilReason

Nil

Op.make.nil("aborted"); // { kind: "OpNil", reason: "aborted" }

ok: <A>(value) => Ok<A> = makeOk

Creates an Ok outcome with the given value.

A

A

Ok<A>

Op.make.ok(42); // { kind: "OpOk", value: 42 }

map: <E, A, B>(f) => (outcome) => Outcome<E, B>

E

A

B

(a) => B

(outcome) => Outcome<E, B>

mapError: <E, F, A>(f) => (outcome) => Outcome<F, A>

E

F

A

(e) => F

(outcome) => Outcome<F, A>

match: <E, A, B>(cases) => (outcome) => B

E

A

B

(e) => B

() => B

(a) => B

(outcome) => B

race: <E, A>(invocations) => Deferred<Outcome<E, A>>

E

A

readonly Deferred<Outcome<E, A>>[]

Deferred<Outcome<E, A>>

recover: <E, A, B>(f) => (outcome) => Outcome<E, A | B>

E

A

B

(e) => Outcome<E, B>

(outcome) => Outcome<E, A | B>

tap: <E, A>(f) => (outcome) => Outcome<E, A>

E

A

(a) => void

(outcome) => Outcome<E, A>

to: object

Maybe: <E, A>(outcome) => Maybe<A>

E

A

Outcome<E, A>

Maybe<A>

Result: <E, A>(onNil) => (outcome) => Result<E, A>

E

A

() => E

(outcome) => Result<E, A>

wire: <I, E, A, S>(source, f) => () => void

I

E

A

S extends State<E, A>

Manager<I, E, A, S>

(a) => void

() => void