Event Delegate
Introduction
The MaestroEventDelegate interface defines methods that your application must implement to enable bi-directional communication between the SDK and your app. It serves two purposes:
- Lets the app communicate data changes (key plays, auth) to the SDK
- Lets the SDK communicate events which the app should/may respond to
Key Responsibilities
- Data Provision: Provide flows of key plays data and auth data
- Playback Control: Handle clip playback requests
- Panel Management: Show/hide panel UI
- Analytics: Track impressions and actions
- User Interaction: Handle login clicks and panel selection
Methods
| Method | Description |
|---|---|
| keyPlaysData() | Flow of key plays data managed by the client app |
| authData() | Flow of authentication data to be used by the SDK |
| playClip() | Notifies app that a key plays clip should be played |
| onKeyPlaysRefreshNeeded() | Notifies app to reload key plays data |
| shouldShowPanel() | Notifies app that the panel should be displayed |
| shouldHidePanel() | Notifies app that the panel should be dismissed |
| trackImpression() | Notifies app of user impressions for analytics |
| trackAction() | Notifies app of user actions for analytics |
| onLoginClicked() | Notifies app that the login card was clicked |
| onPanelSelected() | Notifies app that a panel was selected |
Data Classes
| Class | Description |
|---|---|
| MaestroAuthData | Authentication data for SDK (swid and jwtToken) |
| MaestroLoadableResult | Sealed interface for async loading states (Success, Error, Loading) |
| MaestroOverlayEvent | Sealed interface for overlay events (BetWon, Fantasy) |
Implementation Example
class MyActivity : ComponentActivity(), MaestroEventDelegate {
private val _keyPlaysState = MutableStateFlow<MaestroLoadableResult<MaestroKeyPlaysResponse>>(
MaestroLoadableResult.Loading
)
private val _authDataState = MutableStateFlow<MaestroAuthData?>(null)
override fun keyPlaysData(): StateFlow<MaestroLoadableResult<MaestroKeyPlaysResponse>> {
return _keyPlaysState
}
override fun authData(): StateFlow<MaestroAuthData?> {
return _authDataState
}
override fun playClip(index: Int, clipId: String?) {
// Play the clip at the given index
}
override fun onKeyPlaysRefreshNeeded() {
// Reload key plays data
}
override fun shouldShowPanel() {
// Show the panel
}
override fun shouldHidePanel() {
// Hide the panel
}
// Implement other delegate methods...
}