Nui
Loading...
Searching...
No Matches
comment.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <string_view>
8
9namespace Nui::Elements
10{
12 {
13 comment(comment const&) = default;
14 comment(comment&&) = default;
15 comment(std::string_view content)
16 : HtmlElement{"", &CommentElementBridge, Attribute{content, {}, {}}}
17 {}
20 "",
23 obs.value(),
24 [&obs](std::weak_ptr<Dom::ChildlessElement>&& element) {
25 const auto eventId = globalEventContext.registerEvent(Event{
26 [element, &obs](auto eventId) {
27 if (auto shared = element.lock(); shared)
28 {
29 shared->setNodeValue(obs.value());
30 return true;
31 }
32 obs.detachEvent(eventId);
33 return false;
34 },
35 [element]() {
36 return !element.expired();
37 }});
38 obs.attachEvent(eventId);
39 return eventId;
40 },
41 [&obs](EventContext::EventIdType const& id) {
42 obs.detachEvent(id);
43 },
44 },
45 }
46 {}
47 };
48}
Definition attribute.hpp:15
EventRegistry::EventIdType EventIdType
Definition event_context.hpp:40
EventIdType registerEvent(Event event)
Definition event_context.hpp:52
Definition event.hpp:46
Definition html_element.hpp:58
ContainedT & value()
Definition observed_value.hpp:372
void attachEvent(EventContext::EventIdType eventId) const
Definition observed_value.hpp:100
void detachEvent(EventContext::EventIdType eventId) const
Definition observed_value.hpp:108
Definition observed_value.hpp:1283
Definition comment.hpp:10
thread_local EventContext globalEventContext
Definition event_context.cpp:5
constexpr auto CommentElementBridge
Definition html_element_bridges.hpp:34
Definition comment.hpp:12
comment(Nui::Observed< std::string > &obs)
Definition comment.hpp:18
comment(comment &&)=default
comment(comment const &)=default
comment(std::string_view content)
Definition comment.hpp:15