[event] Return std::string_view from get_last_event_type()

This commit is contained in:
J. Nick Koston
2026-01-09 08:07:57 -10:00
parent 3d54ccac65
commit 8a3e26e6e9
6 changed files with 30 additions and 12 deletions
+11
View File
@@ -7,3 +7,14 @@ event:
- template_event_type2
on_event:
- logger.log: Event fired
- lambda: |-
// Test get_last_event_type() returns std::string_view
if (id(some_event).has_event()) {
auto event_type = id(some_event).get_last_event_type();
// Compare with string literal using ==
if (event_type == "template_event_type1") {
ESP_LOGD("test", "Event type is template_event_type1");
}
// Log using %.*s format for string_view
ESP_LOGD("test", "Event type: %.*s", (int) event_type.size(), event_type.data());
}