NovaDI Examples
Interactive demonstrations of NovaDI patterns and usage
📋 About These Examples
This page showcases NovaDI usage patterns through interactive examples that demonstrate different DI features and patterns. Open your browser console (F12) to see detailed execution logs with grouped output showing how dependencies are resolved and services interact.
✨ TypeScript Transformer: NovaDI includes a compile-time transformer that automatically
injects type names into .as<T>() calls, eliminating the need for string literals
while maintaining full type safety. Write clean, intuitive code: .as<ILogger>()
instead of .as<ILogger>("ILogger").
⚡ Performance: For performance benchmarks comparing NovaDI with other DI frameworks, see the Benchmarks page.
📖 Static Examples: All examples below are shown with expanded code snippets. Click the headers to collapse/expand sections.
Example 1: Simplest Case
The absolute simplest usage - just .as<T>() and .resolveType<T>()!
- No Token<T>() needed - transformer injects type names
- No .autoWire() configuration needed
- Clean, intuitive API
Example 2: Basic DI with Autowiring
Dependency injection with autowiring - automatic dependency resolution.
- Interface registration
- Autowired dependencies
- Singleton lifetime
Example 3: Multiple Implementations
Register multiple implementations of the same interface using keyed services.
- Keyed services
- resolveTypeKeyed()
- resolveTypeAll()
Example 4: Autowired Dependencies
Automatic dependency resolution through constructor injection.
- Constructor injection
- Dependency graphs
- Type safety
Example 5: Scoped Containers
Isolated dependency scopes using child containers (per-room isolation).
- Child containers
- Scope isolation
- Shared singletons
Example 6: Complex Automation System
Complete real-world application with complex dependency graphs and automation rules.
- Multi-layer architecture
- Event-driven system
- Multiple keyed services
- Complex dependency graph