52template <
class...
Args>
75 if (_handlers.Empty() && _lifecycle.OnFirst && !_lifecycle.OnFirst())
80 const uint64_t
id = _handlers.Add(std::move(handler));
82 if (_handlers.Remove(
id) && _handlers.Empty() && _lifecycle.OnLast)
89 bool Empty() const noexcept {
return _handlers.Empty(); }
90 size_t Count() const noexcept {
return _handlers.Size(); }
100 _handlers.Dispatch([&](
Handler& handler) { handler(args...); });
Subscription operator+=(Handler handler)
size_t Count() const noexcept
Event(const Event &)=delete
std::function< void(Args...)> Handler
Event(Lifecycle lifecycle)
bool Empty() const noexcept
Event & operator=(const Event &)=delete
Owns one registration and releases it on destruction.
The argument types a command handler's parameter list is written in.
Starting and stopping an Event source, driven by whether anything is listening.
std::function< bool()> OnFirst
std::function< void()> OnLast