Skip to content

Commit

Permalink
feat: add event handlers registry component
Browse files Browse the repository at this point in the history
  • Loading branch information
luisburgos committed Jun 25, 2022
1 parent 05a7eeb commit 8bb97f8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lib/infra/registries.dart
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';
}

0 comments on commit 8bb97f8

Please sign in to comment.