coordinate-components

Share state between Blazor components using cascading values and scoped services.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill coordinate-components-ecodriverltd
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: coordinate-components
Source: https://github.com/ecoDriverltd/FoundryAgentsExperiment/tree/main/.agents/skills/coordinate-components
Command: npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill coordinate-components-ecodriverltd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Blazor components that lack a direct parent-child relationship cannot share state through parameters, and cascading values placed in static layouts fail to reach interactive children across render mode boundaries. This Skill guides you to the correct state-sharing mechanism for each scenario. ## Core Features & Use Cases - Mechanism Selection: Choose between CascadingValue for subtree state, CascadingValueSource<T> via DI for app-wide state across render modes, and scoped services with change events for mutable shared state. - Update Propagation: Use NotifyChangedAsync to push cascading value updates to all subscribers without page reloads, and Action events with InvokeAsync for thread-safe re-rendering. - Use Case: Build a shopping cart badge that multiple pages read and update by registering a scoped CartState service with an OnChange event, subscribing in components, and unsubscribing in Dispose. ## Quick Start Ask the agent to share a theme or cart state across Blazor components that are not in a parent-child relationship.

Frequently Asked Questions about coordinate-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I share state between Blazor components without a parent-child relationship?▼

Use a scoped service with an Action change event for mutable shared state like a cart, or register a CascadingValueSource<T> in DI for app-wide values. Components subscribe to the event or consume the value via [CascadingParameter].

CascadingValue vs CascadingValueSource in Blazor, which should I use?▼

Use CascadingValue for subtree state within a single render mode, such as layout configuration. Use CascadingValueSource<T> registered in DI when the value must reach components across render mode boundaries or app-wide.

Why is my cascading parameter null in interactive Blazor components?▼

A CascadingValue placed in a static SSR layout does not cross render mode boundaries, so interactive children receive null. Fix it by registering a CascadingValueSource<T> in DI or using a scoped service instead.

Should I use scoped or singleton services for state in Blazor Server?▼

Use scoped services for per-user state on Blazor Server, since a singleton is shared across all circuits and leaks one user's data to others. On WebAssembly, singletons are per-tab and safe.

How do I update a cascading value and notify all subscribers in Blazor?▼

Inject the CascadingValueSource<T> and call NotifyChangedAsync with the new value. This re-renders all [CascadingParameter] subscribers without a page reload; never use NavigationManager.Refresh as a substitute.

Why does StateHasChanged throw when called from a timer or background task?▼

StateHasChanged must run on the Blazor dispatcher thread; calling it from a background thread throws InvalidOperationException. Wrap the call in InvokeAsync and unsubscribe the stored delegate in Dispose.