Betting Entertainment Tools

Bet slip

Example how to implement outcome selection with your bet slip integration.

Examples
// Initialize the changeCallback variable
let changeCallback = undefined;

// Function to register a callback for bet slip changes
function onBetSlipChanged(callback) {
    changeCallback = callback;
    changeCallback && changeCallback(betSlipState);
}

// Initialize the betSlipState object
let betSlipState = {
    betslip: [],
    combinedOddsValue: undefined
};

// Function to handle item click
function onItemClick(target, data) {
    if (target === 'externalOutcome') {
        // This is just an example of implementation.
        // Change it with your own betSlip functionality
        const newBet = {
            externalEventId: data.externalEvent.id,
            externalMarketId: data.externalMarket.id,
            externalOutcomeId: data.externalOutcome.id
        };

        betSlipState = {
            betslip: [...betSlipState.betslip, newBet],
            combinedOddsValue: '14.52' // Just an example, replace with your actual calculation
        }

        // Update the betSlipState by adding the new bet and the combinedOddsValue
        changeCallback && changeCallback(betSlipState);
    }
}

SIR('registerAdapter', '{ADAPTER_NAME}', { onBetSlipChanged: onBetSlipChanged });

SIR('addWidget', '#sr-widget', 'betInsights', { onItemClick: onItemClick });

Until a custom adapter is developed, you can use the mockOutcomes adapter for testing purposes. Simply replace {ADAPTER_NAME} with mockOutcomes in your code.

SIR('registerAdapter', 'mockOutcomes', { onBetSlipChanged: onBetSlipChanged });