Skip to main content

Events

The widget will frequently send events to the host application, and receive events from the host application.

Host driven events

The host application can notify the widget of several scenarios using the browser event dispatcher. An example of triggering these events is available as such:

var event = new CustomEvent(eventName, {
detail: {
loggedIn: true,
bonusBalance: 0,
},
});
window.dispatchEvent(event);

Host User state

Event name: host.state.user

Payload/detail:

{
loggedIn: boolean; // To notify BM Widget that the user is logged in and ready to place bets. Otherwise, a "log in" button will be in place of the place bets button in the betslip.
bonusBalance: number; // Pass through a bonus balance in cents ($1 = 100). This enables bonus bets button on the betslip.
}

Description: Notifies the widget of critical information regarding the user.

Show Betslip event

Event name: host.event.toggleBetslip

Description: An on demand event to open the betslip. This is required for responsive betslip management, as the betslip will be by default toggled off.

Widget driven events

The widget notifies the host application of several scenarios on demand. An example of listening to these events is available as such:

window.addEventListener(eventName, (event) => {
if (event.detail) {
// Do something with the payload
}
});

Login event

Event name: bm.event.login

Description: This event will be fired when the user is required to login, such as clicking on the "login" button.

Betslip state

Event name: bm.state.betslip

Description: This event will be fired each time the betslip is updated to reflect the state for the host. This includes the entire array of selections of each bet type. It will be useful to display a count of bet cards in your header. Any error messages will also be handled on the bet level.

Betslip placed

Event name: bm.event.betslipPlaced

Payload/detail: bm.state.betslip array.

Description: This event will be fired when the user clicks place bets on the widget. It is suggested to utilise this for refetching the users balance.

Betslip failure

Event name: bm.event.betslipFailure

Payload/detail:

{
status: number;
message: string;
}

Description: This event will be fired when any bets have failed. It is suggested to utilise this for refetching the users balance.

Bet placed

Event name: bm.event.betPlaced

Payload/detail: Bet

Description: This event will be fired when a bet is successfully placed. It is suggested to utilise this for refetching the users balance as their balance should be credited back.

Bet failure

Event name: bm.event.betFailure

Payload/detail: Bet

Description: This event will be fired when a bet has failed. It is suggested to utilise this for refetching the users balance as their balance should be credited back.