This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk/extension / registerProductClient

registerProductClient() ​

registerProductClient(product, client): void

Registers the object returned by a product package's factory (e.g. the one from createIgaming) as belonging to client, so that queryScope(product) from @getenginex/sdk/query reaches the app client's session (the userId of the user keys) from the product object alone. The registry lives outside the object (in a global WeakMap, without keeping the product from the GC) and holds across the ESM and CJS entries. Calling again with the same product and the same client does nothing; a product is tied to a single client (the key scope never changes session by mistake).

For SDK packages (@getenginex/sdk-igaming, @getenginex/sdk-predictions), not for apps. Requires core >=0.5.0.

Parameters ​

product ​

object

The public object of the product package (the object itself, not a copy).

client ​

EnginexClient

The core client the product uses.

Returns ​

void

Example ​

ts
import type { EnginexClient } from '@getenginex/sdk'
import { getExtensionTransport, registerProductClient } from '@getenginex/sdk/extension'

export function createIgaming(client: EnginexClient): IgamingClient {
  const transport = getExtensionTransport(client)
  const igaming = { casino: createCasinoApi(transport) }
  registerProductClient(igaming, client)
  return igaming
}

Throws ​

CONFIGURATION_ERROR if product is not an object, if it is itself a core client (with session.get()), if client has no session.get() or if product is already tied to another client. Identify it with isEnginexError(error, 'CONFIGURATION_ERROR').