ModuleContext class
Context provided to modules during lifecycle. Provides convenient access to framework services with automatic module ID tracking.
Example:
// In your module
final context = ModuleManager().getContext('my_module');
context?.registerService(
name: 'my_service',
service: () => MyService(),
);
Constructors
- ModuleContext({required String moduleId, required String moduleName, ModuleIdentityToken? identityToken, SecureServiceRegistry? services, EventBus? eventBus})
Properties
- eventBus → EventBus
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- identityToken → ModuleIdentityToken?
-
The identity token issued by the framework to verify this module.
Used for secure inter-module communication.
final
- moduleId → String
-
final
- moduleName → String
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- services → SecureServiceRegistry
-
final
Methods
-
emit<
T extends ModuleEvent> (T event) → void - Emit a typed event
-
emitSignal(
String signalName, {dynamic data}) → void - Emit a named signal with identity verification. Automatically includes the identityToken to allow the receiver to verify that the signal truly originated from this module.
-
getSecureData<
T> (String key) → T? - Retrieve shared data while handling secure metadata and access control.
-
getService<
T> (String serviceName) → T? - Get a service by name
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on<
T extends ModuleEvent> (void callback(T event)) → EventSubscription - Subscribe to a typed event
-
onSignal(
String signalName, void callback(dynamic data)) → EventSubscription - Subscribe to a named signal
-
registerService(
{required String name, required Function service, List< String> allowedCallers = const []}) → void - Register a service with this module as owner
-
setSecureData<
T> (String key, T value, {bool encrypt = false, Duration? ttl}) → void - Set shared data with optional encryption and time-to-live (TTL).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited