/** * @since 1.0.0 */ import type * as Effect from "@effect/io/Effect" import type * as Exit from "@effect/io/Exit" import * as internal from "@effect/io/internal/resource" import type * as Schedule from "@effect/io/Schedule" import type * as Scope from "@effect/io/Scope" import type * as ScopedRef from "@effect/io/ScopedRef" /** * @since 1.0.0 * @category symbols */ export const ResourceTypeId: unique symbol = internal.ResourceTypeId /** * @since 1.0.0 * @category symbols */ export type ResourceTypeId = typeof ResourceTypeId /** * A `Resource` is a possibly resourceful value that is loaded into memory, and * which can be refreshed either manually or automatically. * * @since 1.0.0 * @category models */ export interface Resource extends Resource.Variance { /** @internal */ readonly scopedRef: ScopedRef.ScopedRef> /** @internal */ acquire(): Effect.Effect } /** * @since 1.0.0 */ export declare namespace Resource { /** * @since 1.0.0 * @category models */ export interface Variance { readonly [ResourceTypeId]: { _E: (_: never) => E _A: (_: never) => A } } } /** * Creates a new `Resource` value that is automatically refreshed according to * the specified policy. Note that error retrying is not performed * automatically, so if you want to retry on errors, you should first apply * retry policies to the acquisition effect before passing it to this * constructor. * * @since 1.0.0 * @category constructors */ export const auto: ( acquire: Effect.Effect, policy: Schedule.Schedule ) => Effect.Effect> = internal.auto /** * Retrieves the current value stored in the cache. * * @since 1.0.0 * @category getters */ export const get: (self: Resource) => Effect.Effect = internal.get /** * Creates a new `Resource` value that must be manually refreshed by calling * the refresh method. Note that error retrying is not performed * automatically, so if you want to retry on errors, you should first apply * retry policies to the acquisition effect before passing it to this * constructor. * * @since 1.0.0 * @category constructors */ export const manual: ( acquire: Effect.Effect ) => Effect.Effect> = internal.manual /** * Refreshes the cache. This method will not return until either the refresh * is successful, or the refresh operation fails. * * @since 1.0.0 * @category utils */ export const refresh: (self: Resource) => Effect.Effect = internal.refresh