Skip to main content
Version: v1

IFluidSerializer Interface

Signature

export interface IFluidSerializer

Methods

Method Return Type Description
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(value, bind) any

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

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

parse(value) any Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid handles will be realized as part of the parse
stringify(value, bind) string Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.

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

Parameter Type Description
input any

Returns

Return type: any

encode

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

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

Signature

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

Parameters

Parameter Type Description
value any
bind IFluidHandle

Returns

Return type: any

parse

Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid handles will be realized as part of the parse

Signature

parse(value: string): any;

Parameters

Parameter Type Description
value string

Returns

Return type: any

stringify

Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.

Signature

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

Parameters

Parameter Type Description
value any
bind IFluidHandle

Returns

Return type: string