Skip to content

@opencraft/providence


Interface: Patcher\<T, AttrName>

Defined in: singles/types/Patcher.ts:8

A wrapper class around individual attributes on a single.

Type Parameters

T

T

AttrName

AttrName extends keyof T

Properties

attrName

attrName: AttrName

Defined in: singles/types/Patcher.ts:18

The name of the field we're tracking on the single.


cached

cached: T[AttrName] | null

Defined in: singles/types/Patcher.ts:27

The most recently set value on the field through the patcher. Compared against the real value on the single x's field to determine if the value is dirty.


controller

controller: SingleController\<T>

Defined in: singles/types/Patcher.ts:22

A reference to the SingleController, used for internal functions.


debouncedRawSet

debouncedRawSet: DebouncedFunc\<(val) => void>

Defined in: singles/types/Patcher.ts:69

The debounced function that set calls. You usually don't want to call this directly. If you do, you'll probably want to set cache first.


dirty

dirty: boolean

Defined in: singles/types/Patcher.ts:31

A getter that returns true if the cached value does not match the value on the single's x.


errors

errors: string[]

Defined in: singles/types/Patcher.ts:44

An array of derived errors from the server when trying to patch this field.


loaded

loaded: boolean

Defined in: singles/types/Patcher.ts:40

Whether the underlying value has been loaded successfully (that is, is x set on the SingleController?)


model

model: T[AttrName]

Defined in: singles/types/Patcher.ts:50

A getter and setter that invokes the patch requesting machinery. That is, set this value to send a patch request.

This value will return the cached value. Setting this value is equivalent to running set.


moduleType

moduleType: "patcher"

Defined in: singles/types/Patcher.ts:14

Returns 'patcher', the type of 'module' this wrapper handles. Technically patchers aren't modules, since their state is shared with singles, however this makes it consistent with similarly behaving controllers, which should have a moduleType property for easy identification.


patching

patching: boolean

Defined in: singles/types/Patcher.ts:35

Whether a patch request is currently being sent. You might use this to determine whether a spinner should be shown.


rawSet

rawSet: (val) => void

Defined in: singles/types/Patcher.ts:64

The raw set function that debouncedSet debounces. You usually don't want to call this directly. If you do, you'll probably want to set cache first. This function performs the actual patch request and handles the resulting server response.

Parameters

val

T[AttrName]

Returns

void


rawValue

rawValue: T[AttrName]

Defined in: singles/types/Patcher.ts:54

Gets the current value of the attrName field on x.


set

set: (val) => void

Defined in: singles/types/Patcher.ts:58

Sets a new value for the field, updating the :js:attr:cache and then running debouncedSet.

Parameters

val

T[AttrName]

Returns

void