Skip to main content

onKeyPlaysRefreshNeeded

Notifies the client app to make a new load of the key plays data.

Overview

The SDK calls this method when it needs fresh key plays data. This can occur when the user manually requests a refresh, when the SDK detects stale data, or when event data changes. Your app should reload key plays data and emit the new values through the keyPlaysData() flow.

Syntax

abstract fun onKeyPlaysRefreshNeeded()

Example

override fun onKeyPlaysRefreshNeeded() {
// Trigger a reload of key plays data
lifecycleScope.launch {
loadKeyPlays()
}
}

private suspend fun loadKeyPlays() {
// Emit loading state
_keyPlaysState.value = MaestroLoadableResult.Loading

try {
// Fetch fresh data from API
val response = apiClient.fetchKeyPlays(forceRefresh = true)

// Emit success state
_keyPlaysState.value = MaestroLoadableResult.Success(response)
} catch (e: Exception) {
// Emit error state
_keyPlaysState.value = MaestroLoadableResult.Error(e)
}
}

Notes

  • This method is called when the SDK needs fresh data
  • Reload data from your source (API, cache, etc.)
  • Emit new values through the keyPlaysData() StateFlow
  • Handle errors gracefully by emitting an error state
  • Consider implementing cache invalidation for force refresh