Skip to content

API reference > @kontsedal/olas-core > Query

Query type ​

A module-scoped shared query handle. Bind a subscriber viacreateQuery(ctx, query, () => [...args]). The same Query value can be used by many controllers across many roots — each root has its own cache. Use bindQuery(ctx, query) or root.bindQuery(query) for imperative operations. Unbound operations reject/throw when more than one root has touched the query.

Signature:

typescript
type Query<Args extends unknown[], T> = {
  readonly [BRAND]: 'query';
  invalidate(...args: Args): Promise<void>;
  invalidateAll(): Promise<void>;
  setData(...args: [...Args, updater: (prev: T | undefined) => T]): Snapshot;
  write(...args: [...Args, updater: (prev: T | undefined) => T]): void;
  replace(...args: [...Args, value: T]): void;
  peek(...args: Args): T | undefined;
  cancel(...args: Args): void;
  cancelAll(): void;
  prefetch(...args: Args): Promise<T>;
};

References: Snapshot

Released under the MIT License.