fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
This commit is contained in:
45
docs/api/core/event/Invoke.md
Normal file
45
docs/api/core/event/Invoke.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Event::Invoke
|
||||
|
||||
```cpp
|
||||
void Invoke(Args... args);
|
||||
```
|
||||
|
||||
调用所有订阅的回调。
|
||||
|
||||
**描述**
|
||||
|
||||
依次调用所有已订阅的回调函数。在调用前会自动处理待退订的回调。回调是在锁外执行的,因此可以在回调中安全地进行订阅/退订操作。线程安全。
|
||||
|
||||
**参数:**
|
||||
- `args` - 传递给回调的参数
|
||||
|
||||
**复杂度:** O(n) 其中 n 为订阅数量
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/Event.h>
|
||||
|
||||
using namespace XCEngine::Core;
|
||||
|
||||
// 无参数事件
|
||||
Event<> frameEndEvent;
|
||||
frameEndEvent.Subscribe([]() {
|
||||
printf("Frame ended\n");
|
||||
});
|
||||
|
||||
// 带参数事件
|
||||
Event<int, const char*> playerDiedEvent;
|
||||
playerDiedEvent.Subscribe([](int playerId, const char* reason) {
|
||||
printf("Player %d died: %s\n", playerId, reason);
|
||||
});
|
||||
|
||||
// 触发事件
|
||||
frameEndEvent.Invoke();
|
||||
playerDiedEvent.Invoke(1, "fell off a cliff");
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [Event 总览](event.md) - 返回类总览
|
||||
- [Subscribe](Subscribe.md) - 订阅事件
|
||||
Reference in New Issue
Block a user