36 lines
2.8 KiB
Markdown
36 lines
2.8 KiB
Markdown
|
|
---
|
|||
|
|
source_files:
|
|||
|
|
- Common/DTS.Common/Events/Realtime/RealtimeChannelSelectedEvent.cs
|
|||
|
|
generated_at: "2026-04-16T03:24:41.583856+00:00"
|
|||
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|||
|
|
schema_version: 1
|
|||
|
|
sha256: "f8835260c1874944"
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# Realtime
|
|||
|
|
|
|||
|
|
## 1. Purpose
|
|||
|
|
This module defines the `RealtimeChannelSelectedEvent` class, a Prism `PubSubEvent` used to broadcast notifications across the application whenever a realtime communication channel is selected. Its role is to decouple the selection logic (e.g., UI interaction or configuration change) from downstream components (e.g., data handlers, UI panels, or connection managers) that need to react to channel changes—such as updating active subscriptions, switching data streams, or refreshing UI elements tied to the selected channel.
|
|||
|
|
|
|||
|
|
## 2. Public Interface
|
|||
|
|
- **`RealtimeChannelSelectedEvent`**
|
|||
|
|
- *Inherits from*: `PubSubEvent<IRealtimeChannel>`
|
|||
|
|
- *Behavior*: A concrete event type that carries an `IRealtimeChannel` payload. When published (via `EventAggregator.Publish()`), it notifies all subscribers that a new realtime channel has been selected. Subscribers receive the selected channel instance as the event argument.
|
|||
|
|
|
|||
|
|
## 3. Invariants
|
|||
|
|
- The event payload is guaranteed to be non-null *at the time of publication*, assuming callers follow the intended usage pattern (publishing only when a valid channel is selected).
|
|||
|
|
- The event is strictly *asynchronous* and *loosely coupled*—publishing does not block, and subscribers execute independently.
|
|||
|
|
- The event type is immutable by design (no custom logic beyond inheritance); behavior is defined entirely by Prism’s `PubSubEvent` infrastructure.
|
|||
|
|
|
|||
|
|
## 4. Dependencies
|
|||
|
|
- **Depends on**:
|
|||
|
|
- `Prism.Events` (for `PubSubEvent<TPayload>`)
|
|||
|
|
- `DTS.Common.Interface.Realtime` (for `IRealtimeChannel` interface)
|
|||
|
|
- **Depended upon by**:
|
|||
|
|
- Any component that needs to react to realtime channel selection changes (e.g., UI views, service layers managing subscriptions). Specific dependents are not visible in this file but would typically subscribe via `EventAggregator.GetEvent<RealtimeChannelSelectedEvent>().Subscribe(...)`.
|
|||
|
|
|
|||
|
|
## 5. Gotchas
|
|||
|
|
- **No null-safety enforcement**: While the event payload is expected to be non-null, Prism’s `PubSubEvent` does not enforce this. Callers must ensure only valid `IRealtimeChannel` instances are published.
|
|||
|
|
- **Lifetime management**: Subscribers must manually unsubscribe (e.g., in `Dispose` or view cleanup) to avoid memory leaks—especially for long-lived subscribers (e.g., services) subscribing to this short-lived event.
|
|||
|
|
- **No ordering guarantees**: Multiple subscribers execute in an undefined order; if sequential logic is required (e.g., cleanup before setup), explicit coordination is needed.
|
|||
|
|
- **None identified from source alone.**
|