本文主要是介绍Flutter 模块内部通知 - (基于 fish_redux 插件),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.生成通知事件处理类 NotificationActionCreator
enum NotificationAction {toNotify, // 通用通知
}
// 添加回调block
typedef ActionCallBack = void Function(dynamic result);static Action toNotify({dynamic object, ActionCallBack completion}) {return Action(NotificationAction.toNotify, payload: {"id": object,"completion": completion,});}
}
2.使用fish_redux 事件广播broadcast
effect 事件处理 添加对应触发点
// 填充参数
ctx.broadcast(NotificationActionCreator.toNotify(object: id,completion: (result) {// 回调参数可调整},));
3.业务类 添加 通知监听
NotificationAction.toNotify: _onToNotification,
_onToNotification() 方法 添加 ActionCallBack completion; 处理回调参数
这篇关于Flutter 模块内部通知 - (基于 fish_redux 插件)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!