Signals
Signals in dill-pixel provide a type-safe event system for communication between different parts of your application. The framework extends the typed-signals
library to add priority ordering and convenience methods.
Core Concepts
Signal Priorities
Signals can be ordered using predefined priorities or custom numeric values:
Basic Usage
Connection Methods
Standard Connection
One-time Connection
N-times Connection
Managing Connections
Manual Disconnection
Disconnecting All
Scene Cleanup
In scenes, use addSignalConnection
to automatically manage signal lifecycles:
Core Application Signals
The Application provides several built-in signals through ICoreSignals:
Best Practices
-
Type Safety
- Always define signal types explicitly for better type inference
- Use TypeScript interfaces for complex signal payloads
-
Connection Management
- Use
addSignalConnection
in scenes (or any class extending dill pixel’sContainer
class) for automatic cleanup - Disconnect manual connections when no longer needed
- Consider using
connectOnce
for one-time events
- Use
-
Priority Usage
- Use predefined priorities for common cases
- Reserve custom numeric priorities for specific ordering requirements
- Keep priority system consistent across your application
-
Performance
- Avoid creating signals in tight loops
- Clean up connections when components are destroyed
- Use
connectOnce
orconnectNTimes
instead of manual disconnection when appropriate