12 template <
typename ValueT>
17 return onEvent(obs.
value());
25 template <
typename ValueT>
28 return listen(eventContext, obs, [onEvent = std::move(onEvent)](ValueT
const& value) {
34 template <
typename ValueT,
typename FunctionT>
37 return listen(eventContext, obs, std::function(std::move(onEvent)));
40 template <
typename ValueT>
44 std::function<
bool(ValueT
const&)> onEvent)
47 [weak = std::weak_ptr<Observed<ValueT>>{obs}, onEvent = std::move(onEvent)](
auto) {
48 if (
auto obs = weak.lock(); obs)
49 return onEvent(obs->
value());
52 [weak = std::weak_ptr<Observed<ValueT>>{obs}]() {
53 return !weak.expired();
58 template <
typename ValueT>
62 std::function<
void(ValueT
const&)> onEvent)
64 return listen(eventContext, obs, [onEvent = std::move(onEvent)](ValueT
const& value) {
70 template <
typename ValueT,
typename FunctionT>
73 return listen(eventContext, obs, std::function(std::move(onEvent)));
76 template <
typename ValueT,
typename FunctionT>
82 template <
typename ValueT,
typename FunctionT>
This object can be copied with low cost.
Definition: event_context.hpp:38
EventIdType registerEvent(Event event)
Definition: event_context.hpp:52
ContainedT const & value() const
Definition: observed_value.hpp:313
void attachEvent(EventContext::EventIdType eventId) const
Definition: observed_value.hpp:62
Definition: observed_value.hpp:1202
Definition: file_dialog.hpp:6
void listen(EventContext &eventContext, Observed< ValueT > const &obs, std::function< bool(ValueT const &)> onEvent)
Definition: listen.hpp:13
thread_local EventContext globalEventContext
Definition: event_context.cpp:5
Definition: observed_value.hpp:1463