Interface: StateConfigWrapper<K, V>
@lexical/utils.StateConfigWrapper
A wrapper that creates bound functions and methods for the StateConfig to save some boilerplate when defining methods or exporting only the accessors from your modules rather than exposing the StateConfig directly.
Type parameters
Name | Type |
---|---|
K | extends string |
V | V |
Properties
$get
• Readonly
$get: <T>(node
: T
) => V
(node) => $getState(node, stateConfig)
Type declaration
▸ <T
>(node
): V
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Parameters
Name | Type |
---|---|
node | T |
Returns
V
Defined in
packages/lexical-utils/src/index.ts:878
$set
• Readonly
$set: <T>(node
: T
, valueOrUpdater
: ValueOrUpdater
<V
>) => T
(node, valueOrUpdater) => $setState(node, stateConfig, valueOrUpdater)
Type declaration
▸ <T
>(node
, valueOrUpdater
): T
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Parameters
Name | Type |
---|---|
node | T |
valueOrUpdater | ValueOrUpdater <V > |
Returns
T
Defined in
packages/lexical-utils/src/index.ts:880
accessors
• Readonly
accessors: readonly [<T>(node
: T
) => V
, <T>(node
: T
, valueOrUpdater
: ValueOrUpdater
<V
>) => T
]
[$get, $set]
Defined in
packages/lexical-utils/src/index.ts:885
stateConfig
• Readonly
stateConfig: StateConfig
<K
, V
>
A reference to the stateConfig
Defined in
packages/lexical-utils/src/index.ts:876
Methods
makeGetterMethod
▸ makeGetterMethod<T
>(): (this
: T
) => V
() => function () { return $get(this) }
Should be called with an explicit this
type parameter.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
fn
▸ (this
): V
Parameters
Name | Type |
---|---|
this | T |
Returns
V
Example
class MyNode {
// …
myGetter = myWrapper.makeGetterMethod<this>();
}
Defined in
packages/lexical-utils/src/index.ts:899
makeSetterMethod
▸ makeSetterMethod<T
>(): (this
: T
, valueOrUpdater
: ValueOrUpdater
<V
>) => T
() => function (valueOrUpdater) { return $set(this, valueOrUpdater) }
Must be called with an explicit this
type parameter.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
fn
▸ (this
, valueOrUpdater
): T
Parameters
Name | Type |
---|---|
this | T |
valueOrUpdater | ValueOrUpdater <V > |
Returns
T
Example
class MyNode {
// …
mySetter = myWrapper.makeSetterMethod<this>();
}