Skip to main content
Version: v1

FluidSerializer Class

Data Store serializer implementation

Signature​

export declare class FluidSerializer implements IFluidSerializer

Implements: IFluidSerializer

Constructors​

ConstructorDescription
(constructor)(context, handleParsedCb)Constructs a new instance of the FluidSerializer class

Properties​

PropertyTypeDescription
IFluidSerializerthis

Methods​

MethodReturn TypeDescription
decode(input)any

Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.

The original input object is not mutated. This method will shallowly clone all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

The decoded handles are implicitly bound to the handle context of this serializer.

encode(input, bind)any

Given a mostly-jsonable object tree that may have handle objects embedded within, will return a fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.

The original input object is not mutated. This method will shallowly clone all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

Any unbound handles encountered are bound to the provided IFluidHandle.

parse(input)any
serializeHandle(handle, bind){ type: string; url: string; }
stringify(input, bind)string

Constructor Details​

(constructor)​

Constructs a new instance of the FluidSerializer class

Signature​

constructor(context: IFluidHandleContext, handleParsedCb: (handle: IFluidHandle) => void);

Parameters​

ParameterTypeDescription
contextIFluidHandleContext
handleParsedCb(handle: IFluidHandle) => void

Property Details​

IFluidSerializer​

Signature​

get IFluidSerializer(): this;

Type: this

Method Details​

decode​

Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.

The original input object is not mutated. This method will shallowly clone all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

The decoded handles are implicitly bound to the handle context of this serializer.

Signature​

decode(input: any): any;

Parameters​

ParameterTypeDescription
inputany

Returns​

Return type: any

encode​

Given a mostly-jsonable object tree that may have handle objects embedded within, will return a fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.

The original input object is not mutated. This method will shallowly clone all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

Any unbound handles encountered are bound to the provided IFluidHandle.

Signature​

encode(input: any, bind: IFluidHandle): any;

Parameters​

ParameterTypeDescription
inputany
bindIFluidHandle

Returns​

Return type: any

parse​

Signature​

parse(input: string): any;

Parameters​

ParameterTypeDescription
inputstring

Returns​

Return type: any

serializeHandle​

Signature​

protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle): {
type: string;
url: string;
};

Parameters​

ParameterTypeDescription
handleIFluidHandle
bindIFluidHandle

Returns​

Return type: { type: string; url: string; }

stringify​

Signature​

stringify(input: any, bind: IFluidHandle): string;

Parameters​

ParameterTypeDescription
inputany
bindIFluidHandle

Returns​

Return type: string