Watch.ts overview

Change events published by a volume's watch stream, and the options that narrow a watch to one object's subtree.

Since v0.6.0


models

CallerWatchOptions (type alias)

Options for a caller watch.

Signature

export type CallerWatchOptions = {
  readonly recursive?: boolean
  readonly alias?: "all" | "resolved"
}

Source

Since v0.9.0

Change (type alias)

One committed change observed through a watch subscription.

Signature

export type Change =
  | { readonly _tag: "Create"; readonly path: BytePath }
  | { readonly _tag: "Update"; readonly path: BytePath }
  | { readonly _tag: "Remove"; readonly path: BytePath }
  | { readonly _tag: "Rescan"; readonly path: BytePath }

Source

Since v0.6.0

WatchOptions (type alias)

Options of a watch.

Signature

export type WatchOptions = { readonly recursive?: boolean; readonly scope?: ObjectReference }

Source

Since v0.6.0

schemas

CallerWatchOptions

Options for a caller watch. resolved follows the selected path alias through rename and ends when that name is unlinked. all reports every currently authorized alias of the object.

Signature

declare const CallerWatchOptions: Schema.Struct<{
  readonly recursive: Schema.optionalKey<Schema.Boolean>
  readonly alias: Schema.optionalKey<Schema.Literals<readonly ["all", "resolved"]>>
}>

Source

Since v0.9.0

Change

Schema for one committed change. Rescan means the subscriber lost events and must rescan what it watches, whose path it names; events are never replayed.

Signature

declare const Change: Schema.TaggedUnion<{
  readonly Create: Schema.TaggedStruct<"Create", { readonly path: Schema.declare<BytePath, BytePath> }>
  readonly Update: Schema.TaggedStruct<"Update", { readonly path: Schema.declare<BytePath, BytePath> }>
  readonly Remove: Schema.TaggedStruct<"Remove", { readonly path: Schema.declare<BytePath, BytePath> }>
  readonly Rescan: Schema.TaggedStruct<"Rescan", { readonly path: Schema.declare<BytePath, BytePath> }>
}>

Source

Since v0.6.0

WatchOptions

Schema for the options of a watch. scope narrows the watch to one object and, when recursive is not false, everything below it; without a scope the watch covers the volume.

Details

The scope is an object, not a path: a watch on a directory keeps receiving its changes, at their current paths, after the directory or one of its ancestors is renamed. Each change is tested against the scope on its own, so a move out of the scope arrives as Remove and a move into it as Create. With recursive: false only the object itself and its direct children are reported. When the object's last name is removed the watch reports Remove for it and ends.

Signature

declare const WatchOptions: Schema.Struct<{
  readonly scope: Schema.optionalKey<Schema.declare<ObjectReference, ObjectReference>>
  readonly recursive: Schema.optionalKey<Schema.Boolean>
}>

Source

Since v0.6.0