Components that can't derive from RfEventComponent (third-party or legacy components) can still
read hub state through an ordinary [CascadingParameter].
How it works
Try it: change each theme. The two cards don't affect each other.
PlainThemedCardis a plainComponentBasewith[CascadingParameter] ThemeState? Theme. It knows nothing about the hub.- In the first card,
options.CascadeRootState<ThemeState>()(seeEventsDemoHub.Configure) exposes the root theme as aCascadingValueSource<ThemeState>. - In the second card,
<StateScope TState="ThemeState" CascadeValue="true">provides a separate instance to its subtree and also cascades it. ThemePickerresolves the nearest provider, so the same component writes the root theme in the first card and the scoped theme in the second.- Trade-off: cascade consumers re-render on every change. Event-aware consumers can use selectors (
ThemePickeronly watchesName).