API reference@evolu/commonResource › createSharedResourceByKeyWithClaims

function createSharedResourceByKeyWithClaims<K, C, T, D, LK, LC>(
  create: (key: K) => Task<T, never, D>,
  __namedParameters?: SharedResourceByKeyWithClaimsOptions<K, C, T, LK, LC>,
): Task<SharedResourceByKeyWithClaims<K, C, T>, never, D>;

Defined in: packages/common/src/Resource.ts:1169

Creates SharedResourceByKeyWithClaims.

The create callback is called with a resource key when that resource must be created. The returned Task must not fail. Its dependencies are captured when the registry is created; later claim calls do not require or replace them.

Transition callbacks represent semantic claim-resource pair changes and are not called when this registry or its Run tree drains claims during disposal. They must not throw. If a first-claim callback defects after earlier callbacks in the same claim completed, matching last-claim callbacks compensate those completed transitions in reverse order before cleanup. Relation reads during compensation still include the failed claim. Callback defects panic the owner Run after claim metadata and resource ownership are cleaned up.

Transition callbacks may synchronously read relation state. They must not call claim, release a ClaimLease owned by this registry, or dispose this registry.

Transition callbacks do not report actual resource disposal. Disposal can happen later when idleDisposeAfter is configured.