dispatch<T extends JState> method
- JIntent<
T> intent, - JController<
T> controller
override
Dispatches the given intent to the provided controller.
The intent represents an action or event that can modify the controller's state. The implementation should ensure the intent is invoked appropriately.
Implementation
@override
Future<void> dispatch<T extends JState>(
JIntent<T> intent,
JController<T> controller,
) async {
if (!controller.mounted) {
throw StateError('JController has been disposed.');
}
final slot = (controller, _keyOf(intent));
if (!_running.add(slot)) {
if (kDebugMode) {
debugPrint('⏭️ [JIntent][DROP] Dropped ${intent.runtimeType}');
}
JObserver.notifyIntentDropped(intent);
return;
}
try {
await intent.run(controller);
JObserver.notifyIntentCompleted(intent);
} finally {
_running.remove(slot);
}
}