当前位置:网站首页>(forwarding articles) after skipping multiple pages, shuttle returns to the first page and passes parameters
(forwarding articles) after skipping multiple pages, shuttle returns to the first page and passes parameters
2022-06-25 09:51:00 【Moon Spring】
Link to the original text :https://blog.csdn.net/u013491829/article/details/105313600
Event distribution EventBus Tool class
// Subscriber callback signature
typedef void EventCallback(arg);
class EventBus {
// Private constructor
EventBus._internal();
// Save single example
static EventBus _singleton = new EventBus._internal();
// Factory constructor
factory EventBus()=> _singleton;
// Save the event subscriber queue ,key: Event name (id),value: Subscriber queue corresponding to the event
var _emap = new Map<Object, List<EventCallback>>();
// Add subscribers
void on(eventName, EventCallback f) {
if (eventName == null || f == null) return;
_emap[eventName] ??= new List<EventCallback>();
_emap[eventName].add(f);
}
// Remove subscribers
void off(eventName, [EventCallback f]) {
var list = _emap[eventName];
if (eventName == null || list == null) return;
if (f == null) {
_emap[eventName] = null;
} else {
list.remove(f);
}
}
// Triggering event , After the event is triggered, all subscribers of the event will be called
void emit(eventName, [arg]) {
var list = _emap[eventName];
if (list == null) return;
int len = list.length - 1;
// Reverse traversal , Prevent subscribers from removing subscript misalignment caused by themselves in the callback
for (var i = len; i > -1; --i) {
list[i](arg);
}
}
}
// Define a top-level( overall situation ) Variable , The page can be used directly after importing the file bus
var bus = new EventBus();
Use event distribution
//Page 1、2、3、4 in
...
bus.on(" Tag of agreed enjoyment event ", (arg) {
// do something
});
Send parameters to the subscription interface
...
//
bus.emit(" Tag of agreed enjoyment event ", " Parameters passed ");
边栏推荐
- Download the arm64 package of Debian on X86 computer
- Voiceprint Technology (V): voiceprint segmentation and clustering technology
- 力扣-104. 二叉树的最大深度
- Fcpx quickly add subtitles | Final Cut Pro import fcpxml subtitle file does not match the video time? I got it in code
- Why should the terminal retail industry choose the member management system
- 处理图片类库
- PHP obtains the IP address, and the apache2 server runs without error
- The way that flutter makes the keyboard disappear (forwarding from the dependent window)
- js工具函数,自己封装一个节流函数
- Neat Syntax Design of an ETL Language (Part 2)
猜你喜欢

Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial

manhattan_ Slam environment configuration

Fcpx quickly add subtitles | Final Cut Pro import fcpxml subtitle file does not match the video time? I got it in code

Ruiji takeout project (II)
![[design completion - opening report] zufeinfo 2018 software engineering major (including FAQ)](/img/b7/fb7ead787e00047f3663e8b5acfe33.jpg)
[design completion - opening report] zufeinfo 2018 software engineering major (including FAQ)

How to "transform" small and micro businesses (II)?
![[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate](/img/75/a06e20b4394579cbd9f6d3a075907a.jpg)
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate

With the QQ group file storage function of super nice, you immediately have n cloud disks that are easy to download and never expire

Remittance international empowers cross-border e-commerce: to be a compliant cross-border payment platform!

Applet cloud development joint table data query and application in cloud function
随机推荐
SQL advanced
[MySQL learning notes 21] storage engine
MySQL创建给出语句
独步武林,架构选型手册(包含 PDF)
manhattan_ Slam environment configuration
[zero foundation understanding innovation and entrepreneurship competition] overall cognition and introduction of mass entrepreneurship and innovation competition (including FAQs and integration of bl
[project part - structure and content writing of technical scheme] software system type mass entrepreneurship and innovation project plan and Xinmiao guochuang (Dachuang) application
可穿戴设备或将会泄露个人隐私
Rxjs TakeUntil 操作符的学习笔记
Etcd教程 — 第四章 Etcd集群安全配置
华泰证券在上面开户安全吗?靠谱吗?
Format analysis and explanation of wav file
Creating a binary tree (binary linked list) from a generalized table
[buuctf.reverse] 121-125
Huipay international permet au commerce électronique transfrontalier de devenir une plate - forme de paiement transfrontalière conforme!
富时A50开户什么地方安全
[buuctf.reverse] 117-120
[IOU] intersection over union
Mysql 源码阅读(二)登录连接调试
PMP考试多少分算通过?