interface ViewConnection<TState> extends ViewClient<TState> The runtime half of a generated client: one presentation of a route, registered with open. Generated code is its only intended caller. Values and inputs are encoded as their wire types; undefined as an input means the command takes none. Calls that change state resolve once the route's state includes their effects (the reply's revision), with the exposed state at that moment.
Properties
route
readonly route: string; The route of this presentation.
requests
readonly requests: Readonly<Record<string, ViewRequestSurface>>; The View's view requests by name (specs/application/README.md, "View requests"), whose handlers this presentation registers; an empty object for a View without view requests.
Methods
set
set(member: string, value: unknown): Promise<TState>; A generated setter: sends set with the member's next edit number and exposes value (decoded with the member's decoder) in snapshot until the edit's revision arrives or the edit fails. A superseded edit resolves like an applied one.
command
command(member: string, input?: unknown): Promise<TState>; Runs a command after the presentation's interaction and view request handlers are registered.
commandOutcome
commandOutcome<TFailure>(member: string, decodeFailure: (value: unknown) => TFailure, input?: unknown): Promise<BridgeOutcome<TState, TFailure>>; Runs a command that declares a failure type, like command. Its declared failure resolves bridgeFailure(decodeFailure(failure)); every other failure still rejects with BridgeError.
can
can(member: string, input?: unknown): Promise<boolean>; Asks whether a command is available for input without running it.
region
region(member: string, action: "select" | "close", key: string): Promise<RegionOutcome>; Selects or closes the region with key of the region collection member (region-collections/1). Resolves with the request's outcome once the route's state includes it; a vetoed request resolves too, with its outcome.
write
write<T>(member: string, request: BridgeFieldWriteRequest, decode: (value: unknown) => T): Promise<FieldWriteReceipt<T>>; A checked write of member; decode decodes the field values of the receipt.
fieldBaseline
fieldBaseline(field: string): FieldBaseline<unknown>; The value and version of a checked field in the producer's state, which a write call is based on.
fieldPathVersion
fieldPathVersion(): number; The version a field path write is based on (field-paths/1): the route's revision.
start
start<TResult, TFailure = never>(member: string, operation: string, input: unknown, codec: BridgeOperationCodec<TResult, TFailure>): Promise<BridgeOperationRuntimeHandle<TResult, TFailure>>; Starts member as an operation with the id operation.
recover
recover<TResult, TFailure = never>(member: string, operation: string, codec: BridgeOperationCodec<TResult, TFailure>): Promise<BridgeOperationRuntimeHandle<TResult, TFailure>>; Returns the operation of member with the id operation, for example after the page reloaded.
queryCollection
queryCollection<TRow>(member: string, definition: QueryCollectionDefinition<TRow>): QueryCollection<TRow>; The rows of the query collection member for this presentation (query-collections/1), disposed with the presentation. Each call creates another, with its own range.