Skip to content

Getting Started

Nicolás Seijas edited this page Jul 20, 2026 · 3 revisions

Getting Started

Rambla targets current .NET (the repo builds on .NET 10). The core is netstandard2.0, so it works broadly; UI integration ships as adapters.

1. Reference the packages

  • Rambla — the framework-agnostic core (includes the [State] source generator).
  • Rambla.Wpf — the WPF dispatcher adapter.

(Packages are not yet published to NuGet; for now reference the projects or build from source. See the Roadmap.)

2. Point Rambla at your UI thread

At application startup, on the UI thread, install a scheduler so background writes marshal correctly:

// WPF, once at startup:
Rambla.Wpf.DispatcherStateScheduler.InstallAsDefault();

Without an adapter, the default is a synchronous ImmediateStateScheduler (useful for tests and non-UI code).

3. Declare state

Inherit RamblaState and annotate backing fields with [State]. The generator emits the observable property (strips a leading underscore: _bidBid).

public partial class MarketViewModel : RamblaState
{
    [State] private decimal _bid;
    [State] private decimal _ask;
    [State] private decimal _pnl;
}

4. Write from anywhere

// From a WebSocket handler, timer, or worker — any thread:
vm.Bid = quote.Bid;
vm.Ask = quote.Ask;
vm.Pnl = quote.Pnl;

No Dispatcher.Invoke, no OnPropertyChanged, no SynchronizationContext.Post. Rambla coalesces the writes and raises PropertyChanged on the UI thread.

5. Batch related writes (optional)

Group writes so the UI is notified once, coherently — never mid-batch:

using (vm.BeginUpdate())
{
    vm.Bid = bid;
    vm.Ask = ask;
    vm.Pnl = pnl;
}
// or: vm.Update(() => { ... });

See Core Semantics for exactly what this guarantees (and what it does not — batches give notification coherence, not cross-thread state atomicity).

6. See it under load

Run the market dashboard sample and watch mutations/s, PropertyChanged/s, coalescing %, flush p50/p95/p99 and producer→visible latency live:

dotnet run -c Release --project samples/Rambla.Demo.MarketDashboard

Clone this wiki locally