17 Log::Error(
"{}: {} event(s) still had handlers when the hook went away; one may dangle.", _name, _listening);
23 return {.
OnFirst = [
this] {
return AddListener(); }, .OnLast = [
this] { RemoveListener(); }};
26bool LazyHook::AddListener()
30 auto hook = _install();
33 Log::Warn(
"{}: {}; its handlers will not fire.", _name,
hook.error().Detail);
36 _hook = std::move(*
hook);
43void LazyHook::RemoveListener()
45 if (_listening > 0 && --_listening == 0)
LazyHook(std::string name, std::function< Result< Subscription >()> install)
EventLifecycle ForEvent()
void Error(std::format_string< Args... > fmt, Args &&... args)
void Warn(std::format_string< Args... > fmt, Args &&... args)
static std::string ReadFile(const std::filesystem::path &path)
std::expected< T, Error > Result
Starting and stopping an Event source, driven by whether anything is listening.
std::function< bool()> OnFirst