update
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
class EventBus:
|
||||
def __init__(self):
|
||||
self.listeners = {} # 管理各种event的订阅情况
|
||||
|
||||
def subscribe(self, event_type, listener):
|
||||
if event_type not in self.listeners:
|
||||
self.listeners[event_type] = []
|
||||
self.listeners[event_type].append(listener)
|
||||
|
||||
def publish(self, event_type, data):
|
||||
if event_type in self.listeners:
|
||||
for listener in self.listeners[event_type]:
|
||||
listener(data)
|
||||
|
||||
# 订阅与发布事件示例
|
||||
# event_bus.subscribe('my_event', handle_event)
|
||||
# event_bus.publish('my_event', {'key': 'value'})
|
||||
@@ -0,0 +1,7 @@
|
||||
from .eventbus import EventBus
|
||||
|
||||
# Pring Log
|
||||
EventPrintLog = "print_log" # 打印日志
|
||||
|
||||
# 创建事件总线实例
|
||||
loggerEBus = EventBus()
|
||||
@@ -0,0 +1,10 @@
|
||||
from eventbus import EventBus
|
||||
|
||||
# 市场数据监听控制事件
|
||||
EventMarketActiveSwitch = "market_active_switch" # 市场数据状态变更
|
||||
MarketDataUpdate = "market_data_update" # 市价更新
|
||||
MarketOrderCreated = "market_order_created" # 市价单创建
|
||||
MarketOrderTraded = "market_order_traded" # 市价单成交
|
||||
|
||||
# 创建事件总线实例
|
||||
marketDataEventBus = EventBus()
|
||||
Reference in New Issue
Block a user