-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add event handlers registry component
- Loading branch information
1 parent
05a7eeb
commit 8bb97f8
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:buzz/buzz.dart'; | ||
|
||
abstract class _IModuleBuzzRegistries<T> { | ||
List<CommandRegistry> get commands; | ||
List<UiEventRegistry> get uiEvents; | ||
List<AppEventRegistry> get appEvents; | ||
} | ||
|
||
abstract class ModuleBuzzRegistries<T> extends _IModuleBuzzRegistries<T> { | ||
@override | ||
List<CommandRegistry> get commands => const []; | ||
|
||
@override | ||
List<AppEventRegistry> get appEvents => const []; | ||
|
||
@override | ||
List<UiEventRegistry> get uiEvents => const []; | ||
} | ||
|
||
abstract class UiEventRegistry extends EventHandlerRegistry<UIEvent> { | ||
UiEventRegistry({ | ||
required Function(UIEvent) handler, | ||
}) : super(handler: handler); | ||
} | ||
|
||
abstract class CommandRegistry extends EventHandlerRegistry<Command> { | ||
CommandRegistry({ | ||
required Function(Command) handler, | ||
}) : super(handler: handler); | ||
} | ||
|
||
abstract class AppEventRegistry extends EventHandlerRegistry<AppEvent> { | ||
AppEventRegistry({ | ||
required Function(AppEvent) handler, | ||
}) : super(handler: handler); | ||
} | ||
|
||
abstract class EventHandlerRegistry<T> { | ||
EventHandlerRegistry({ | ||
required this.handler, | ||
}); | ||
|
||
final Function(T) handler; | ||
|
||
@override | ||
String toString() => '$runtimeType type:$T'; | ||
} |