@grafctory/keep
    Preparing search index...

    Function createBatchingStore

    • Creates a batching store client backed by a set of request handlers.

      Coalesces concurrent StoreClient calls into batches, each served by the matching handlers entry. The client adds conditional CRUD semantics on top of the handlers: create, update and delete probe for existence through the detect handler before handing the mutation to modify. lookup probes for existence the same way, except for a virtual lookup, which goes straight to the detail handler. create mints the identifier of the new resource, if its state names none, and links it to the collecting resource as a new collection member.

      The modify handler receives only requests whose state carries no id other than their entry. A request failing this check is rejected on its own, and the rest of the batch still applies. If the modify handler throws, the error rejects every request in its batch.

      Parameters

      • handlers: {
            detect: Handler<Detect>;
            detail: Handler<Detail<Template, Lazy<ResourceShape>>>;
            select: Handler<Select<Query<Slot>>>;
            modify: Handler<Modify>;
        }

        The batch handlers, one per request type

      • options: { limit?: Limits; scope?: StoreScope } = {}

        The caps on how handlers are called, and the default retrieval scope

        • Optional Readonlylimit?: Limits

          The caps on batch size per request type and on handler calls in flight, matched to what the backend accepts.

          No limit: each handler receives its whole accumulation and every call of a round runs at once
          
        • Optional Readonlyscope?: StoreScope

          The retrieval scope that fills in the members a lookup scope leaves out, one by one, as a fallback rather than a ceiling. The handlers receive the locale priority of the scope as filled in, with the locale the lookup states taking precedence over the default one.

          {}, leaving every lookup within the closed default bounds

      Returns StoreClient

      An immutable StoreClient serving its requests in batches through handlers

      RangeError If an update or insert state carries an id that differs from its entry, or if a create state member filling an identifier slot is not a single path segment