Options
All
  • Public
  • Public/Protected
  • All
Menu

Package effects

@typed/effects

Generator-based effect management and reverse dependency injection.

Index

Type aliases

Capabilities

Capabilities<A>: A extends Effects<infer R, any> ? R : never

Type parameters

  • A

CombinedCapabilities

CombinedCapabilities<A>: UnNest<Flatten<ToConsList<A>, {}>>

Type parameters

  • A: ReadonlyArray<Effect<any, any>>

CombinedValues

CombinedValues<A>: {}

Type parameters

  • A: ReadonlyArray<Effect<any, any>>

Type declaration

ErrorOf

ErrorOf<E, K>: FailuresOf<E>[K] extends Fail<infer R> ? R : never

Type parameters

Fail

Fail<Err>: <A>(error: Err) => Resume<Failure<Err, A>>

Type parameters

  • Err

Type declaration

FailEnv

FailEnv<K, Err>: {}

Type parameters

  • K: PropertyKey

  • Err

Type declaration

FailureTypes

FailureTypes<E>: keyof FailuresOf<E>

Type parameters

FailuresOf

FailuresOf<E>: Pick<Capabilities<E>, FailureKeys<Capabilities<E>>>

Type parameters

FiberFailure

FiberFailure: FailEnv<typeof FiberFailure, Error>

FiberInfo

FiberInfo<B>: { promise: Promise<B>; state: Running } | { error: Error; state: Error } | { state: Returned; value: B }

Type parameters

  • B

Fork

Fork: { fork: <A>(effect: A, c: Capabilities<A> & FiberFailure) => Resume<Fiber<Return<A>>> }

Type declaration

ForkAll

ForkAll<A>: {}

Type parameters

  • A: ReadonlyArray<Effect<any, any>>

Type declaration

IteratorResultOf

IteratorResultOf<A>: IteratorResult<Yield<A>, Return<A>>

Type parameters

  • A

Join

Join: { join: <A>(fiber: Fiber<A>) => Resume<Either<Error, A>> }

Type declaration

JoinAll

JoinAll<A>: {}

Type parameters

  • A: ReadonlyArray<Fiber<any>>

Type declaration

Kill

Kill: { kill: <A>(f: Fiber<A>) => Resume<boolean> }

Type declaration

PureEffect

PureEffect<A>: Effect<Pure<any>, A>

Type parameters

  • A

Return

Return<A>: A extends Effect<any, infer R> ? R : never

Type parameters

  • A

RunWith

RunWith<A, C>: C extends Capabilities<A> ? PureEffect<Return<A>> : Effects<Omit<Capabilities<A>, keyof C>, Return<A>>

Type parameters

TimerEnv

TimerEnv: { timer: Timer }

Type declaration

  • Readonly timer: Timer

TypeOf

TypeOf<A>: A extends Effect<any, any> ? Effects<Capabilities<A>, Return<A>> : A extends (...args: keyof any[]) => Effects<any, any> ? Effects<Capabilities<ReturnType<A>>, Return<ReturnType<A>>> : unknown

Type parameters

  • A

Yield

Yield<A>: A extends Effect<infer R, any> ? R : never

Type parameters

  • A

Variables

Const FiberFailure

FiberFailure: unique symbol = Symbol.for('FiberFailure')

Functions

Const Fail

  • Fail<A>(error: any): { type: "value"; value: A } | { resume: (cb: (value: A) => Disposable) => Disposable; type: "lazy" }

catchFailure

  • catchFailure<A, K>(effect: A, errorType: K, onError: (error: ErrorOf<A, K>) => Return<A>)

combine

createFiber

  • createFiber<A>(): Fiber<A>

Const delay

fail

  • fail<A, Err>(errorType: A, error: Err): Effects<FailEnv<A, Err>, any>

fork

forkAll

Const get

  • get<A>(): Effect<Env<A, A>, A>

join

joinAll

kill

killAll

map

orFail

race

Const runEffect

runEffects

  • runEffects<A>(effect: A): Disposable
  • runEffects<A>(effect: A, resources: Capabilities<A>, onReturn?: undefined | ((value: Return<A>) => Disposable)): Disposable

runWith

  • runWith<A, C>(effect: A, capabilities: C): RunWith<A, C>

sequence

Const startEffect

Object literals

Const Fork

Fork: object

fork

  • fork<A>(effect: A, c: Capabilities<A> & FiberFailure): { type: "value"; value: A } | { resume: (cb: (value: A) => Disposable) => Disposable; type: "lazy" }

Const Join

Join: object

join

Const Kill

Kill: object

kill

Generated using TypeDoc