coordinate-components
Qué hace
Esta skill muestra cómo compartir datos entre componentes Blazor que no están vinculados directamente, como un contador del carrito que se muestra en muchas páginas. Está pensada para desarrolladores de .NET que construyen una interfaz Blazor con estado compartido.
Cuándo usarla
- ✓Cuando un contador del carrito de la compra o una insignia de notificaciones deben mostrarse en varias páginas.
- ✓Cuando un tema o el usuario actual deben llegar a componentes de todo un layout.
- ✓Cuando dos componentes alejados en la página deben reaccionar al mismo cambio.
Link de la skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-blazor/skills/coordinate-components/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Muestra un contador de artículos del carrito en la cabecera que se actualice desde cualquier página de producto de mi app Blazor.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
El agente elige el mecanismo adecuado según el ámbito, como un valor en cascada para un layout o un servicio compartido con evento de cambio, y lo conecta con una limpieza correcta.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Coordinate Components
Step 1 — Read AGENTS.md
Read AGENTS.md at the workspace root to learn the project's conventions before making changes.
Step 2 — Decide the scope
| Need | Mechanism | When to use |
|---|---|---|
| Subtree (same render mode) | CascadingValue component |
Theme, layout config within a layout |
| App-wide (all render modes) | CascadingValueSource<T> via DI |
Current user, feature flags, theme shared globally |
| Mutable shared state within a circuit | Scoped service + Action event |
Shopping cart, notification count, selected filters |
For parent→child one level: use [Parameter] / EventCallback (see author-component skill).
For persisting state across prerender→interactive: see support-prerendering skill.
Workflow (quick reference)
- Choose the mechanism from the table in Step 2
- If crossing render mode boundaries → use
CascadingValueSource<T>(Step 4) - Register in
Program.cswithAddCascadingValue(...)andisFixed: false - Consume via
[CascadingParameter]in child components - Update via
NotifyChangedAsync(newValue)— never page reload - For additional mutable state within a circuit → add scoped service (Step 5)
- Wrap any
StateHasChangedfrom background threads inInvokeAsync - Implement
IDisposable— dispose timers, cancel tokens, unsubscribe events
Step 3 — CascadingValue for subtree state
Wrap a subtree with <CascadingValue> to flow data to all descendants without passing it through every intermediate component.
@* In a layout or parent component *@
<CascadingValue Value="theme">
@Body
</CascadingValue>
@code {
private ThemeInfo theme = new() { ButtonClass = "btn-primary" };
}
Consume in any descendant:
[CascadingParameter]
private ThemeInfo? Theme { get; set; }
Rules:
- Matched by type, not name. To cascade multiple values of the same type, add
Name:<CascadingValue Value="primary" Name="PrimaryTheme">...</CascadingValue>[CascadingParameter(Name = "PrimaryTheme")] private ThemeInfo? Primary { get; set; } - Set
IsFixed="true"when the value never changes — avoids subscription overhead. - Does NOT cross render mode boundaries. A
<CascadingValue>in a static SSR parent is invisible to interactive children. See Step 6.
Step 4 — CascadingValueSource<T> for app-wide state
Register a CascadingValueSource<T> in DI when the value must be available to all components regardless of render mode.
// Program.cs
builder.Services.AddCascadingValue(sp =>
{
var theme = new ThemeInfo { ButtonClass = "btn-primary" };
return new CascadingValueSource<ThemeInfo>(theme, isFixed: false);
});
Consume identically to Step 3:
[CascadingParameter]
private ThemeInfo? Theme { get; set; }
To update and notify subscribers, either mutate the existing object or replace it:
@* Component that changes the theme *@
@inject CascadingValueSource<ThemeInfo> ThemeSource
<button @onclick="ToggleDarkMode">Toggle theme</button>
@code {
private bool isDark;
private async Task ToggleDarkMode()
{
isDark = !isDark;
// Replace the value entirely:
var newTheme = new ThemeInfo { ButtonClass = isDark ? "btn-dark" : "btn-primary" };
await ThemeSource.NotifyChangedAsync(newTheme);
}
}
NotifyChangedAsync() (no argument) also works — mutate the object and then call it. NotifyChangedAsync(newValue) replaces the value and notifies in one step.
Update protocol: Whenever shared state changes, the component that changes it MUST inject CascadingValueSource<T> and call NotifyChangedAsync(). This is the only mechanism that triggers re-rendering in all [CascadingParameter] subscribers. Without this call, no subscribers update. Do not use NavigationManager.Refresh() or page reloads as a substitute.
Rules:
isFixed: falseenables change notifications.isFixed: trueis better for truly static values (feature flags).- Crosses render mode boundaries — works for per-page interactivity, global interactivity, and WebAssembly. Key advantage over
<CascadingValue>. - Keep cascaded types granular. Every
NotifyChangedAsyncre-renders ALL subscribers regardless of which property changed. Don't put all app state into one cascaded type. - For Auto/WebAssembly apps, register in both server and
.ClientProgram.cs. The typ
Preguntas frecuentes
¿Qué es el estado en cascada?
Es una forma de pasar un valor hacia abajo por una parte del árbol de componentes sin pasarlo por cada parámetro.
¿Funciona entre modos de renderizado?
Sí. Cubre compartir estado entre límites de modos de renderizado.
¿Limpia las suscripciones?
Sí. Incluye la liberación de temporizadores, tokens y eventos.
Detalles
Descripción original del autor
Share state between components that don't have a direct parent-child parameter relationship, using cascading values, scoped services with change events, or CascadingValueSource via DI. USE WHEN the user needs a CascadingParameter or CascadingValue that works across render mode boundaries, a shopping cart or notification count accessible from multiple pages, a theme or user preference cascaded app-wide, or when components in different parts of the tree must react when shared data changes. Also USE WHEN cascading values aren't reaching interactive children in per-page interactivity mode, or when
repo: dotnet/skills
Popularidad
- Estrellas en GitHub
- 5,8 mil
- Posición en el ranking
- #14564
- Licencia
- MIT
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
create-custom-agent
5,8 milAyuda a tu agente a crear archivos de agentes personalizados de VS Code, con sus propias herramientas, instrucciones y traspasos a otros agentes.
create-skill
5,8 milAyuda a tu agente a crear una skill nueva de agente con un nombre válido, una descripción de activación clara y un archivo SKILL.md que siga el estándar.
csharp-scripts
5,8 milAyuda a tu agente a ejecutar un pequeño programa en C# como un único archivo con la herramienta de línea de comandos de .NET, sin crear un proyecto completo.
dotnet-pinvoke
5,8 milAyuda a tu agente a llamar correctamente a librerías nativas de C o C++ desde .NET, cubriendo firmas, manejo de cadenas, memoria y handles seguros.
Skills parecidas
angular-developer
280 milAyuda a tu agente con código de Angular y la estructura del proyecto. Útil para empezar proyectos, crear partes de código o mejorar el rendimiento y la accesibilidad.
frontend-a11y
280 milAyuda a tu agente a hacer que las interfaces web sean accesibles para todos. Asegura que sitios y apps funcionen bien con lectores de pantalla y navegación por teclado.
frontend-patterns
280 milHace que tu agente aplique patrones modernos en desarrollo frontend. Optimiza el rendimiento, gestiona el estado y sigue buenas prácticas en React y Next.js.