Fixed the following issues in XCEngine Core module documentation: - Added 'using namespace XCEngine::Core;' to all code examples that use Core types (Event, FileWriter, etc.) without full namespace qualification - Added missing '#include <XCEngine/Containers/String.h>' to FileWriter examples that use Containers::String - Added '#include <string>' to Flush.md example using std::to_string Affected files: - core/core.md: Added using directive and Containers include - event/*.md: Added using namespace to all 8 event doc files - filewriter/*.md: Added using namespace and proper includes to all 6 files
627 B
627 B
Event::Clear
void Clear();
清空所有订阅。
描述
移除所有已订阅的回调,清空事件。线程安全。
复杂度: O(n) 其中 n 为订阅数量
示例:
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
Event<int> event;
// 订阅多个回调
event.Subscribe([](int v) { });
event.Subscribe([](int v) { });
event.Subscribe([](int v) { });
// 清空所有订阅
event.Clear();
// 触发(无回调被执行)
event.Invoke(42);
相关文档
- Event 总览 - 返回类总览
- Unsubscribe - 退订单个事件