currentEventDoesNotSupportKeyPlays
Indicates that the current event does not support key plays functionality.
Overview
Call this method to inform the SDK that the current event does not support key plays functionality. This will update the UI to show an appropriate message to the user and prevent the SDK from attempting to load key plays data for this event.
Method Signature
currentEventDoesNotSupportKeyPlays(): void
Parameters
This method does not take any parameters.
Return Value
This method does not return a value.
Example Usage
import SDK from '@maestro_io/maestro-web-sdk';
// Function to check if an event supports key plays
async function checkEventSupportsKeyPlays(eventID: string): Promise<boolean> {
try {
// Your implementation to check if the event supports key plays
// This could be an API call, a check against a local database, etc.
const supportsKeyPlays = await yourApiClient.checkEventSupportsKeyPlays(eventID);
// If the event doesn't support key plays, notify the SDK
if (!supportsKeyPlays) {
const event = SDK.getMaestroEventViewModel();
event.currentEventDoesNotSupportKeyPlays();
}
return supportsKeyPlays;
} catch (error) {
console.error('Failed to check if event supports key plays:', error);
// Assume the event doesn't support key plays in case of an error
const event = SDK.getMaestroEventViewModel();
event.currentEventDoesNotSupportKeyPlays();
return false;
}
}
// Example of how this might be used when starting to watch an event
async function startWatchingEvent(eventID: string) {
// Create event delegate
const delegate = createEventDelegate();
// Initialize event in the SDK
const event = await SDK.userDidStartWatchingEvent(eventID, delegate);
// Check if the event supports key plays
const supportsKeyPlays = await checkEventSupportsKeyPlays(eventID);
// If the event supports key plays, try to load initial data
if (supportsKeyPlays) {
try {
await delegate.userRequestedNewKeyPlaysData();
} catch (error) {
console.error('Failed to load initial key plays data:', error);
}
}
// Render the panel regardless - it will show the appropriate UI
// based on whether key plays are supported
const unmountFunction = await SDK.renderPanel('panel-container');
// Notify the SDK that the panel is visible
await event.didShowPanel();
return {
event,
unmountFunction,
supportsKeyPlays
};
}
Internal Behavior
When currentEventDoesNotSupportKeyPlays()
is called, the SDK updates the error state in the KeyPlaysViewModel
:
// Example of how this method is implemented in the SDK
currentEventDoesNotSupportKeyPlays(): void {
this.keyPlaysViewModel.errorState.value = 'unsupportedEvent';
}
This changes the UI to display a message indicating that key plays are not supported for this event, rather than showing a loading indicator or an error message.
Error States
The KeyPlaysViewModel
handles several error states:
'unpopulatedEvent'
- Initial state, indicating that key plays data hasn't been loaded yet'unsupportedEvent'
- Set by this method, indicating that the event doesn't support key plays'tabLoadFailure'
- Indicates that there was an error loading the data
Notes
- Call this method as soon as you determine that an event doesn't support key plays, typically after starting to watch the event.
- After calling this method, the SDK will display a message in the key plays panel indicating that this feature is not available for the current event.
- This is different from an error state - it's a valid state for events that simply don't have key plays functionality.
- You don't need to call this method if the event does support key plays but there's no data available yet; in that case, you should call
updateKeyPlaysData()
with an empty data structure or null. - This method is synchronous and doesn't perform any network operations.