Files
XCSDD/docs/api/core/event/Unsubscribe.md
ssdfasd 58a83f445a 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
2026-03-19 12:44:08 +08:00

861 B

Event::Unsubscribe

void Unsubscribe(uint64_t id);

退订事件。

描述

将指定 ID 的回调从订阅列表中移除。退订是延迟生效的,在调用 Invoke 时会一并处理待退订的回调。线程安全,可在任意线程调用。

参数:

  • id - 订阅时返回的 ID

复杂度: O(n) 在 Invoke 时处理

示例:

#include <XCEngine/Core/Event.h>

using namespace XCEngine::Core;

Event<int> someEvent;

// 订阅
uint64_t id = someEvent.Subscribe([](int value) {
    printf("Value: %d\n", value);
});

// 退订
someEvent.Unsubscribe(id);

// 触发(已退订的回调不会被调用)
someEvent.Invoke(42);

相关文档