Tracks a value that is announced by an event and can also be read on demand.
An event has no replay: a subscriber that mounts after the last emission never hears about the
current value. So the hook seeds the value with read (retrying while the read is rejected, for
example while the service behind it is still starting) and then follows event.
An event is always newer than a read that was already in flight when the event arrived, so the
event wins: such a read result is dropped, and an event also ends any pending seed retries. A
recheck does not end them, so a seed read can still follow a value a recheck supplied.
Some values can go stale without a further event (for example when the emitter is restarted). For
those, shouldRecheck plus recheckIntervalMs re-read the value on a timer for as long as it
says the value needs it.
Deliberately takes read and event as callbacks rather than using PAPI itself, so this library
stays free of any PAPI dependency and both the renderer and extension web views can use it with
their own command-sending and event mechanisms.
Tracks a value that is announced by an event and can also be read on demand.
An event has no replay: a subscriber that mounts after the last emission never hears about the current value. So the hook seeds the value with
read(retrying while the read is rejected, for example while the service behind it is still starting) and then followsevent.An event is always newer than a read that was already in flight when the event arrived, so the event wins: such a read result is dropped, and an event also ends any pending seed retries. A recheck does not end them, so a seed read can still follow a value a recheck supplied.
Some values can go stale without a further event (for example when the emitter is restarted). For those,
shouldRecheckplusrecheckIntervalMsre-read the value on a timer for as long as it says the value needs it.Deliberately takes
readandeventas callbacks rather than using PAPI itself, so this library stays free of any PAPI dependency and both the renderer and extension web views can use it with their own command-sending and event mechanisms.