|
@@ -1,15 +1,17 @@
|
|
|
/** 一个事件能存储多个回调 */
|
|
/** 一个事件能存储多个回调 */
|
|
|
-interface enentNames {
|
|
|
|
|
|
|
+interface EnentNames {
|
|
|
loadComplete: string; //加载状态名
|
|
loadComplete: string; //加载状态名
|
|
|
|
|
+ spotTrade: string; // 挂牌成功,通知报价大厅更新数据
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 一个事件只能存储一个回调 */
|
|
/** 一个事件只能存储一个回调 */
|
|
|
-interface enentNames_onlyOneValue {
|
|
|
|
|
|
|
+interface EnentNamesOnlyOneValue {
|
|
|
logout: string; //登出名:确认登出时不能进行其它操作了 暂时1s登出状态
|
|
logout: string; //登出名:确认登出时不能进行其它操作了 暂时1s登出状态
|
|
|
loginSuccess: string; // 登录成功
|
|
loginSuccess: string; // 登录成功
|
|
|
loadAddressList: string; //加载地址列表
|
|
loadAddressList: string; //加载地址列表
|
|
|
loadMylieList: string; //加载闲置列表
|
|
loadMylieList: string; //加载闲置列表
|
|
|
|
|
|
|
|
|
|
+
|
|
|
custOfflineNtf: string; //接收到账户离线通知
|
|
custOfflineNtf: string; //接收到账户离线通知
|
|
|
userLogout: string; //接收到用户登出应答
|
|
userLogout: string; //接收到用户登出应答
|
|
|
posChangedNtf: string; //接收到头寸变化通知
|
|
posChangedNtf: string; //接收到头寸变化通知
|
|
@@ -24,19 +26,19 @@ export default new (class Bus {
|
|
|
private subscribe: { [key: string]: Array<Function> } = {};
|
|
private subscribe: { [key: string]: Array<Function> } = {};
|
|
|
|
|
|
|
|
/** 注册事件(一个事件可以存储多个回调) */
|
|
/** 注册事件(一个事件可以存储多个回调) */
|
|
|
- $on(enentType: keyof enentNames, hander: Function): void {
|
|
|
|
|
|
|
+ $on(enentType: keyof EnentNames, hander: Function): void {
|
|
|
this.subscribe[enentType] = this.subscribe[enentType] || [];
|
|
this.subscribe[enentType] = this.subscribe[enentType] || [];
|
|
|
this.subscribe[enentType].push(hander);
|
|
this.subscribe[enentType].push(hander);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 注册事件(一个事件只能存储一个回调) */
|
|
/** 注册事件(一个事件只能存储一个回调) */
|
|
|
- $onOnly(enentType: keyof enentNames_onlyOneValue, hander: Function): void {
|
|
|
|
|
|
|
+ $onOnly(enentType: keyof EnentNamesOnlyOneValue, hander: Function): void {
|
|
|
this.subscribe[enentType] = [];
|
|
this.subscribe[enentType] = [];
|
|
|
this.subscribe[enentType].push(hander);
|
|
this.subscribe[enentType].push(hander);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 发布事件 立即执行*/
|
|
/** 发布事件 立即执行*/
|
|
|
- $emit(enentType: keyof enentNames | keyof enentNames_onlyOneValue, data?: any): void {
|
|
|
|
|
|
|
+ $emit(enentType: keyof EnentNames | keyof EnentNamesOnlyOneValue, data?: any): void {
|
|
|
const sub = this.subscribe[enentType];
|
|
const sub = this.subscribe[enentType];
|
|
|
if (sub) {
|
|
if (sub) {
|
|
|
sub.forEach((hander: Function) => hander(data));
|
|
sub.forEach((hander: Function) => hander(data));
|
|
@@ -44,7 +46,7 @@ export default new (class Bus {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 取消部分订阅
|
|
// 取消部分订阅
|
|
|
- $off(enentType: keyof enentNames | keyof enentNames_onlyOneValue, hander: Function): void {
|
|
|
|
|
|
|
+ $off(enentType: keyof EnentNames | keyof EnentNamesOnlyOneValue, hander: Function): void {
|
|
|
const sub = this.subscribe[enentType];
|
|
const sub = this.subscribe[enentType];
|
|
|
if (sub) {
|
|
if (sub) {
|
|
|
const findIndex = sub.findIndex((fn) => fn === hander);
|
|
const findIndex = sub.findIndex((fn) => fn === hander);
|
|
@@ -53,7 +55,7 @@ export default new (class Bus {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 取消所有订阅
|
|
// 取消所有订阅
|
|
|
- $offall(enentType: keyof enentNames): void {
|
|
|
|
|
|
|
+ $offall(enentType: keyof EnentNames): void {
|
|
|
const sub = this.subscribe[enentType];
|
|
const sub = this.subscribe[enentType];
|
|
|
if (sub) {
|
|
if (sub) {
|
|
|
delete this.subscribe[enentType];
|
|
delete this.subscribe[enentType];
|