UUnrealReactBridgeSubsystem
Source: SampleProject/Plugins/UnrealReactBridge/Source/UnrealReactBridge/Public/UnrealReactBridgeSubsystem.h
UGameInstanceSubsystem that owns the HUD-widget registry and routes events between Sender/Receiver components and the active UWebHUDWidget instances. HUD widgets self-register in NativeConstruct and unregister in NativeDestruct, so most users never touch the subsystem directly — drop a ReactBridgeSender / ReactBridgeReceiver component and the wiring is automatic.
Use the subsystem directly when you need:
- A targeted send from C++ without spawning a Sender component.
- A targeted send from a Blueprint that doesn't have a Sender on hand (e.g. Game Mode, Subsystem, REST callback).
- Diagnostics — manual broadcast during debugging.
TIP
Broadcasts that arrive before any HUD widget has registered are buffered (up to 100 entries) and flushed when the first widget registers. This means GameMode::BeginPlay initial-state pushes are safe even though the Level Blueprint creates the widget afterwards.
Get
static UUnrealReactBridgeSubsystem* Get(UWorld* World);BlueprintCallable. Convenience accessor — resolves the owning UGameInstance from World and returns its subsystem, or nullptr if either is unavailable.
| Param | Type | Required | Notes |
|---|---|---|---|
World | UWorld* | yes | Any world reference (GetWorld(), WorldContextObject->GetWorld()) |
Returns — Subsystem pointer or nullptr.
BroadcastEvent
void BroadcastEvent(const FString& EventName, const FString& JsonData);Fans the event out to every registered HUD widget in the current GameInstance.
| Param | Type | Required | Notes |
|---|---|---|---|
EventName | FString | yes | Case-sensitive event name. Matches React-side window.ue.bridge.on(name, ...) subscriptions. |
JsonData | FString | yes | Valid JSON string. Pass "{}" for no payload. Reaches React as event.detail. |
Returns — void.
Behavior — If no widget is registered yet, the broadcast is buffered (FIFO, capped at 100). The buffer drains the moment the first widget registers.
Example
if (auto* Sub = UUnrealReactBridgeSubsystem::Get(GetWorld()))
{
Sub->BroadcastEvent(TEXT("game:paused"), TEXT("{\"reason\":\"menu\"}"));
}SendEvent
void SendEvent(const FString& BridgeName, const FString& EventName, const FString& JsonData);Targeted send — delivers only to the widget whose BridgeName matches.
| Param | Type | Required | Notes |
|---|---|---|---|
BridgeName | FString | yes | Case-sensitive. Must match UWebHUDWidget::BridgeName (or the Name of an Add Web HUD layer). |
EventName | FString | yes | Case-sensitive event name. |
JsonData | FString | yes | Valid JSON string; "{}" for no payload. |
Returns — void.
Behavior — Silently no-ops if BridgeName does not match any registered widget. If Debug Mode is enabled in Project Settings, the miss is reported in the Output Log. Targeted sends are not buffered: deliver-or-drop.
Example
if (auto* Sub = UUnrealReactBridgeSubsystem::Get(GetWorld()))
{
Sub->SendEvent(TEXT("HpBar"), TEXT("player:health:update"),
TEXT("{\"value\":75,\"max\":100}"));
}See also
/guide/sender-receiver— when to use components vs the subsystem/reference/bridge-protocol— wire format and event delivery rules