123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import 'package:fis_common/event/event_type.dart';
- import 'package:flutter/foundation.dart';
- /// 消息处理器
- abstract class IHandler<T> {
- /// 类型Int值
- int get typeInt;
- /// 执行处理程序
- ///
- /// [message] 消息实例
- void execute(T message);
- }
- /// 可分发
- abstract class IDistributable<T> {
- /// 订阅
- ///
- /// [callback] 订阅消息回调函数
- void subscribe(ValueChanged<T> callback);
- /// 取消订阅
- ///
- /// [callback] 订阅消息回调函数
- void unsubscribe(ValueChanged<T> callback);
- }
- /// 处理器提供者
- abstract class IHandlerProvider {
- /// 获取处理器
- ///
- /// [type] 消息类型
- IHandler? getHandler(int type);
- }
- /// 可注册处理器
- abstract class IHandlerRegistrable {
- /// 注册处理器
- ///
- /// [handler] 处理器
- void register<T>(IHandler<T> handler);
- /// 撤销注册
- void deregister<T>(IHandler<T> handler);
- }
|