Skip to content

Commit 227ae1b

Browse files
committed
注释
1 parent f0d18a2 commit 227ae1b

File tree

14 files changed

+1886
-388
lines changed

14 files changed

+1886
-388
lines changed

deva.sublime-workspace

Lines changed: 82 additions & 126 deletions
Large diffs are not rendered by default.

deva/bus.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
11
#!/usr/bin/env python
2+
"""总线模块,提供全局事件流和日志功能
3+
4+
本模块提供了一个全局事件总线系统,用于在不同组件间传递消息和事件。
5+
主要包含以下功能:
6+
7+
1. log流: 用于全局日志记录
8+
2. warn流: 用于警告信息
9+
3. debug流: 用于调试信息
10+
4. bus: 通用事件总线
11+
12+
主要组件:
13+
--------
14+
log : NS
15+
全局日志流,缓存最近消息
16+
warn : NS
17+
警告信息流,输出到logging
18+
debug : NS
19+
调试信息流
20+
bus : NT
21+
通用事件总线,用于组件间通信
22+
23+
示例:
24+
-----
25+
# 基本日志
26+
'hello' >> log # 输出日志
27+
28+
# 警告信息
29+
'warning!' >> warn # 输出警告
30+
31+
# 调试信息
32+
'debug info' >> debug # 输出调试信息
33+
34+
# 事件总线
35+
def handler(msg):
36+
print('收到消息:', msg)
37+
38+
bus.sink(handler) # 注册处理器
39+
'event' >> bus # 发送事件
40+
41+
# 函数调试
42+
@debug # 装饰器方式
43+
def foo():
44+
pass
45+
46+
f = range+sum # 函数组合
47+
ff = f^debug # 添加调试
48+
'123' >> ff # 执行时输出调试信息
49+
"""
50+
251
"""公共总线流.
352
453
Exsample::

0 commit comments

Comments
 (0)