The useMatchContext composable provides a shared reactive reference to the current match context. It enables components across the application to access information about the currently active match, including its ID, display text, and associated tournament.
Since the return value is a reactive reference, you can update it from any component:
const matchContext = useMatchContext();// Set the match contextmatchContext.value = { id: 'match-123', displayText: 'Team Alpha vs Team Beta', tournament: { id: 'tournament-456', name: 'Summer Championship 2024' }};// Clear the match contextmatchContext.value = null;
This composable uses a module-level ref, meaning the match context is shared across all components that use it. Changes in one component will be reflected in all others.
The match context should be set when navigating to match-specific pages and cleared when navigating away to prevent stale data.