Interface: Serializer
Encodes and decodes values and calls against a tree, with a list of value serializers.
Created with createSerializer.
Every operation takes the root of the tree as its first argument; it must be a tree root.
Properties
serializers
readonly serializers: readonly ValueSerializer<any, any>[];
The list of value serializers it was created with, without the built-ins.
Methods
decodeCall()
decodeCall(root, json): ResolvedCall;
Decodes a call encoded with encodeCall: the target is resolved and the name resolved on
it, nothing is run. The arguments are decoded when args is first read.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | object | Root of the tree. |
json | | JsonValue | EncodedCall | The encoded call. |
Returns
The resolved call, to pass to applyCall or applyCallAsync.
decodeValue()
decodeValue(root, json): unknown;
Decodes a value encoded with encodeValue. References are resolved against the tree;
snapshots become new instances.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | object | Root of the tree. |
json | JsonValue | Value to decode. |
Returns
unknown
The decoded value.
encodeCall()
encodeCall(root, call): EncodedCall;
Encodes a call (an ActionCall, e.g. from onActionMiddleware's onStart, or a Call)
as JSON. The target always goes as a reference; for a standalone action, it isn't repeated
in the arguments.
Encode an ActionCall before the action runs (e.g. in onStart), so its arguments are
encoded against the tree the receiver has.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | object | Root of the tree. |
call | ActionCall | Call | The call. |
Returns
The encoded call.
encodeValue()
encodeValue(root, value): JsonValue;
Encodes a value as JSON. Nodes of the tree go as references when a reference serializer in the list claims them.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | object | Root of the tree. |
value | unknown | Value to encode. |
Returns
The encoded value.