Events Tutorials

Step-by-step guides for RForge.Blazor.Events

Step-by-step guides for using RForge.Blazor.Events in a Blazor app. They assume you already know Blazor components, dependency injection and render modes, and explain only what's specific to the hub.

Start with Setup. After that, each tutorial stands alone: it has its own small example, so you can jump straight to the topic you need.

#TutorialYou'll learn
01 Setup Install the package, register the hub, lay out your project, build your first event-aware component
02 State Define state, read it reactively with [UseState], write it, and use selectors to limit re-renders
03 State with cascades Let plain (or third-party) components read hub state through [CascadingParameter]
04 Events Define events, publish them, handle them with [Subscribe], and decide when to use an event vs. state
05 Scopes and routing Fence events into a subtree with <EventScope> and choose where events travel with routes
06 Scoped state Give each instance of a widget its own copy of a state with <StateScope>
07 Services and background work Publish and subscribe from services, timers and other threads
08 Prerendering and persistence Keep state loaded during prerendering when the page becomes interactive
09 Render modes What works where (Static, Server, WebAssembly, Auto), and the island boundary
10 Manual registration Subscribe without attributes: parameter-dependent selectors, dynamic subscriptions
11 Testing with bUnit Unit-test event-aware components
12 Troubleshooting Every RFEVT diagnostic and the most common runtime mistakes
13 Best practices One-page checklist: project layout, file placement, naming, design rules

Two conventions used everywhere

Every event-aware component in these tutorials follows two rules. Setup explains why.

  1. The .razor file starts with @inherits RfEventComponent.
  2. [Subscribe] and [UseState] members live in the code-behind (.razor.cs), never in an @code block.

Each code block starts with a comment giving the file path it belongs in, for example // MyApp.Client/Features/Counter/CounterState.cs. The paths follow the recommended project layout.

See also

An unhandled error has occurred. Reload 🗙