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
interface BettingAPI {
  registerCallbacks(callbacks: BettingCallbacks): void;
  subscribe(event: IBettingEvent, handler: (data: IBettingEventPayload) => void): () => 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.

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.