Skip to content

API reference > @kontsedal/olas-core > bindQuery

bindQuery() function ​

Bind a query value to this controller's root, for imperative reads and writes outside a subscription (§5.5, §6.4). options.origin tags the handle's writes for plugins.

Signature:

typescript
export declare function bindQuery<Args extends unknown[], T>(ctx: Ctx, query: Query<Args, T>, options?: BindQueryOptions): QueryActions<Args, T>;

Parameters ​

Parameter

Type

Description

ctx

Ctx

query

Query<Args, T>

options

BindQueryOptions

(Optional)

Returns:

QueryActions<Args, T>

Example ​

ts
const userMenu = defineController((ctx) => {
  const users = bindQuery(ctx, userQuery)
  return {
    prefetchUser: (id: string) => users.prefetch(id),
    refreshUser: (id: string) => users.invalidate(id),
  }
})

Released under the MIT License.