Interface: Patcher<T, AttrName>
singles/types/Patcher.Patcher
A wrapper class around individual attributes on a single.
Type parameters
Name | Type |
---|---|
T |
T |
AttrName |
extends keyof T |
Properties
attrName
• attrName: AttrName
The name of the field we're tracking on the single.
Defined in
src/base/singles/types/Patcher.ts:18
cached
• cached: null
| T
[AttrName
]
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.
Defined in
src/base/singles/types/Patcher.ts:27
cancelController
• Private
cancelController: AbortController
The AbortController <https://developer.mozilla.org/en-US/docs/Web/API/AbortController>
_ used to abort patch
requests.
Defined in
src/base/singles/types/Patcher.ts:76
controller
• controller: SingleController
<T
>
A reference to the SingleController, used for internal functions.
Defined in
src/base/singles/types/Patcher.ts:22
debouncedRawSet
• debouncedRawSet: DebouncedFunc
<(val
: T
[AttrName
]) => void
>
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.
Defined in
src/base/singles/types/Patcher.ts:69
dirty
• dirty: boolean
A getter that returns true
if the cached value does not match the value on the single's x
.
Defined in
src/base/singles/types/Patcher.ts:31
errors
• errors: string
[]
An array of derived errors from the server when trying to patch this field.
Defined in
src/base/singles/types/Patcher.ts:44
getSetting
• Private
getSetting: settingName
: Setting
) => PatcherState
<T
, AttrName
>[Setting
]
Type declaration
▸ <Setting
>(settingName
): PatcherState
<T
, AttrName
>[Setting
]
Retrieves a setting for this patcher in the state manager.
Type parameters
Name | Type |
---|---|
Setting |
extends keyof PatcherState <T , AttrName > |
Parameters
Name | Type |
---|---|
settingName |
Setting |
Returns
PatcherState
<T
, AttrName
>[Setting
]
Defined in
src/base/singles/types/Patcher.ts:90
loaded
• loaded: boolean
Whether the underlying value has been loaded successfully (that is, is x
set on the
SingleController?)
Defined in
src/base/singles/types/Patcher.ts:40
model
• model: T
[AttrName
]
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.
Defined in
src/base/singles/types/Patcher.ts:50
moduleType
• moduleType: "patcher"
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.
Defined in
src/base/singles/types/Patcher.ts:14
patching
• patching: boolean
Whether a patch request is currently being sent. You might use this to determine whether a spinner should be shown.
Defined in
src/base/singles/types/Patcher.ts:35
rawSet
• rawSet: (val
: T
[AttrName
]) => void
Type declaration
▸ (val
): void
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
Name | Type |
---|---|
val |
T [AttrName ] |
Returns
void
Defined in
src/base/singles/types/Patcher.ts:64
rawValue
• rawValue: T
[AttrName
]
Gets the current value of the attrName field on x
.
Defined in
src/base/singles/types/Patcher.ts:54
set
• set: (val
: T
[AttrName
]) => void
Type declaration
▸ (val
): void
Sets a new value for the field, updating the :js:attr:cache
and then running debouncedSet.
Parameters
Name | Type |
---|---|
val |
T [AttrName ] |
Returns
void
Defined in
src/base/singles/types/Patcher.ts:58
setSetting
• Private
setSetting: <Setting>(settingName
: Setting
, val
: PatcherState
<T
, AttrName
>[Setting
]) => void
Type declaration
▸ <Setting
>(settingName
, val
): void
Updates a setting for this patcher in the state manager.
Type parameters
Name | Type |
---|---|
Setting |
extends keyof PatcherState <T , AttrName > |
Parameters
Name | Type |
---|---|
settingName |
Setting |
val |
PatcherState <T , AttrName >[Setting ] |
Returns
void
Defined in
src/base/singles/types/Patcher.ts:82
toJSON
• Private
toJSON: () => { attrName
: AttrName
; controller
: string
; moduleType
: "patcher"
; rawValue
: T
[AttrName
] }
Type declaration
▸ (): Object
Custom JSON serializer to prevent infinite loops during serialization.
Returns
Object
Name | Type |
---|---|
attrName |
AttrName |
controller |
string |
moduleType |
"patcher" |
rawValue |
T [AttrName ] |