Initial reference to this handle.
Filesystem path to be watched.
Watcher-specific options
Logging and parcel watcher options
The client to forward events to.
Amount of time in ms to wait once this handle is not referenced anymore.
ProtecteddebugUsed for debugging to keep track of the watchers.
Protected ReadonlydeferredThis deferred only rejects with WatcherDisposal and never resolves.
Protected ReadonlydeferredAmount of time in ms to wait once this handle is not referenced anymore.
ProtecteddeferredWhen the ref count hits zero, we schedule this watch handle to be disposed.
ProtecteddisposedProtected ReadonlyfileThe client to forward events to.
ReadonlyfsFilesystem path to be watched.
ProtectedparcelEnsures that events are processed in the order they are emitted, despite being processed async.
Protected ReadonlyparcelLogging and parcel watcher options
Protected ReadonlyrefsWe count each reference made to this watcher, per client.
We do this to know where to send events via the network.
An entry should be removed when its value hits zero.
ProtectedwatcherWhen this field is set, it means the watcher instance was successfully started.
ReadonlywatcherWatcher-specific options
ReadonlywhenResolves once this handle disposed itself and its resources. Never throws.
ReadonlywhenPromise that resolves when the watcher is fully started, or got disposed.
Will reject if an error occurred while starting.
Protected StaticdebugProtected_Internal disposal mechanism.
Protectedassertwith WatcherDisposal if this instance is disposed.
ProtectedcreateProtecteddebugeslint-disable-next-line @typescript-eslint/no-explicit-any
ProtectedfireAll clients with at least one active reference.
Add the references for each client together.
ProtectedhandleProtectedinfoeslint-disable-next-line @typescript-eslint/no-explicit-any
ProtectedisReturns true if at least one client listens to this handle.
ProtectedonWhen references hit zero, we'll schedule disposal for a bit later.
This allows new references to reuse this watcher instead of creating a new one.
e.g. A frontend disconnects for a few milliseconds before reconnecting again.
ProtectedonIf we get new references after hitting zero, let's unschedule our disposal and keep watching.
ProtectedpushProtectedresolveProtectedstartWhen starting a watcher, we'll first check and wait for the path to exists before running a parcel watcher.
ProtectedstopGiven a started parcel watcher instance, gracefully shut it down.
Because URIs can be watched by different clients, we'll track how many are listening for a given URI.
This component wraps the whole start/stop process given some reference count.
Once there are no more references the handle will wait for some time before destroying its resources.