Repository navigation
Integrations
DxMessaging integrates with three Unity DI frameworks: VContainer, Zenject, and Reflex. This section shows how to bind IMessageBus in each container, use scoped lifetimes for per-scene buses, and inject IMessageRegistrationBuilder so handlers stay testable.
DI and messaging cover different concerns:
- Constructor Injection -- for service dependencies (repositories, managers, configuration)
- Messaging -- for reactive events (damage taken, item collected, game state changes)
This combination provides:
- Explicit dependencies with testable constructors
- Loose coupling between systems via events
- Scoped message buses for scene isolation
- Clean separation of concerns
These are setup fragments for the callbacks named below. Each helper registers a new bus for its container. Follow the linked guides to register builders and services.
Call the helper inside LifetimeScope.Configure(IContainerBuilder builder):
using DxMessaging.Unity.Integrations.VContainer;
builder.RegisterDxMessagingBus();Call the helper inside MonoInstaller.InstallBindings(), using its Container property:
using DxMessaging.Unity.Integrations.Zenject;
Container.BindDxMessagingBus();Call the helper inside IInstaller.InstallBindings(ContainerBuilder builder):
using DxMessaging.Unity.Integrations.Reflex;
builder.AddDxMessagingBus();| Framework | Configuration pattern |
|---|---|
| VContainer |
LifetimeScope.Configure and service entry-point registrations |
| Zenject |
MonoInstaller.InstallBindings in the context's installer list |
| Reflex |
IInstaller.InstallBindings discovered under its ContainerScope
|
All frameworks support the same core patterns:
-
Global Bus -- Explicitly bind
MessageHandler.MessageBuswhen the container should share the global bus - Scoped Bus -- Register a new bus in each scene or feature container and emit on the bus resolved from that container
-
Builder Injection -- Bind
IMessageRegistrationBuilderthrough the framework setup; each independent service owns and disposes its lease -
Testable Design -- Use an isolated
MessageBusper test and verify delivery and cleanup
See each framework's guide for detailed examples and best practices.
- Getting-Started-Overview
- Getting-Started-Getting-Started
- Getting-Started-Install
- Getting-Started-Quick-Start
- Getting-Started-Visual-Guide
- Concepts-Message-Types
- Concepts-Listening-Patterns
- Concepts-Targeting-And-Context
- Concepts-Interceptors-And-Ordering
- Guides-Patterns
- Guides-Unity-Integration
- Guides-Testing
- Guides-Diagnostics
- Guides-Advanced
- Guides-Migration-Guide
- Advanced-Emit-Shorthands
- Advanced-Message-Bus-Providers
- Advanced-Runtime-Configuration
- Advanced-String-Messages
- Reference-Reference
- Reference-Quick-Reference
- Reference-Helpers
- Reference-Faq
- Reference-Glossary
- Reference-Troubleshooting
- Reference-Compatibility
Links