register method
注册监听
Implementation
bool register(String key, EventListen listen, {bool replace = true}) {
///需要返回订阅者,所以不能使用下面这种形式
///没有指定类型,全类型注册
if (!replace) {
if (_streamState.containsKey(key)) {
return false;
}
} else {
_streamListen[key] = listen;
if (!_streamState.containsKey(key)) {
_controller[key] = StreamController<_EventData>.broadcast();
Stream<_EventData> stream = _controller[key]!.stream.cast<_EventData>();
_streamState[key] = stream.listen(_listenCallback);
}
}
return true;
}