MCPcopy Create free account
hub / github.com/Effect-TS/effect / result

Function result

packages/effect/src/unstable/reactivity/AtomRegistry.ts:875–896  ·  view source on GitHub ↗
(this: Lifetime<any>, atom: Atom.Atom<Result.AsyncResult<A, E>>, options?: {
    readonly suspendOnWaiting?: boolean | undefined
  })

Source from the content-addressed store, hash-verified

873 },
874
875 result<A, E>(this: Lifetime<any>, atom: Atom.Atom<Result.AsyncResult<A, E>>, options?: {
876 readonly suspendOnWaiting?: boolean | undefined
877 }): Effect.Effect<A, E> {
878 if (this.disposed || this.isFn) {
879 return this.resultOnce(atom, options)
880 }
881 const result = this.get(atom)
882 if (options?.suspendOnWaiting && result.waiting) {
883 return Effect.never
884 }
885 switch (result._tag) {
886 case "Initial": {
887 return Effect.never
888 }
889 case "Failure": {
890 return Exit.failCause(result.cause)
891 }
892 case "Success": {
893 return Effect.succeed(result.value)
894 }
895 }
896 },
897
898 resultOnce<A, E>(this: Lifetime<any>, atom: Atom.Atom<Result.AsyncResult<A, E>>, options?: {
899 readonly suspendOnWaiting?: boolean | undefined

Callers 3

effect.tsFile · 0.50
orElseFunction · 0.50
matcher.tsFile · 0.50

Calls 3

resultOnceMethod · 0.80
getMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected