Skip to content

combine

combine<E, A, B>(resourceA, resourceB): Resource<E, readonly [A, B]>

Defined in: Core/Resource.ts:120

Acquires two resources in sequence and presents them as a tuple. Resources are released in reverse order: the second is released before the first.

If the second resource fails to acquire, the first is released immediately before returning the error.

E

A

B

Resource<E, A>

Resource<E, B>

Resource<E, readonly [A, B]>

const combined = Resource.combine(dbResource, cacheResource);

const result = await pipe(
  combined,
  Resource.use(([conn, cache]) => lookupWithFallback(conn, cache, userId))
)();