Effect CommunityEC
Effect Communityβ€’2mo agoβ€’
23 replies
harrysolovay

Built-in Utility for Caching Effect Results in Effect Typescript?

Is there any built-in utility for caching an effect's result outside of the effect plane? Ie. something like the following:

export const cache = <A>(x: Effect.Effect<A>): Effect.Effect<A> => {
  let pending: Promise<A> | undefined
  return Effect.promise(() => pending ?? (pending = Effect.runPromise(x)))
}
Was this page helpful?