Skip to content

BettingAPI

The BettingAPI provides methods for interacting with the betting SPA once it has been initialized. You can use it to configure various aspects of the betting interface, such as change theme, listen events, setup callbacks, etc.

An instance of the BettingAPI is passed to the onLoad callback of the bettingLoader.load() method and is also made available globally via the window object

1
2
3
4
5
6
7
interface BettingAPI {
  registerCallbacks(callbacks: BettingCallbacks): void;
  subscribe(event: IBettingEvent, handler: (data: IBettingEventPayload) => void): () => void;
  updateBettingOptions(options: {token: string}): void;
  updateThemeConfig(themeConfig: Partial<ThemeConfig>): void;
  destroy(): void;
}

registerCallbacks

Description: Registers a set of callbacks that the betting SPA can use to interact with the integrator.

Parameters: callbacks (BettingCallbacks) — An object containing the callback functions.

subscribe

Description: Subscribes to a specific betting event.

Parameters: event (BettingEvents) — The name of the event to subscribe to. handler — A callback function that will be executed when the event is triggered.

Returns: A function that, when called, unsubscribes the handler from the event.

updateBettingOptions

Description:
Updates the token for the betting SPA.

Authorization data, currency, and locale are injected into the token (Token), so when any of these values change, the token must be re-generated and updated.

This method can be used in scenarios such as:

  • when the user login / logout

  • when the language is changed on the main website

  • when the currency is changed on the main website

Parameters:

  • token – Token of the current player (Token)

updateThemeConfig

Description: Updates the theme configuration of the betting SPA.

Parameters: themeConfig (ThemeConfig) — An object containing the new theme configuration.

destroy

Description: Destroys the betting SPA instance, cleaning up any resources or event listeners.