Skip to main content
Version: v1

PureDataObject Class

This is a bare-bones base class that does basic setup and enables for factory on an initialize call. You probably don't want to inherit from this data store directly unless you are creating another base data store class

Signature

export declare abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes> extends EventForwarder<I["Events"] & IEvent> implements IFluidLoadable, IFluidRouter, IProvideFluidHandle

Extends: EventForwarder<I["Events"] & IEvent

Implements: IFluidLoadable, IFluidRouter, IProvideFluidHandle

Type Parameters

Parameter Constraint Default Description
I DataObjectTypes DataObjectTypes The optional input types used to strongly type the data object

Constructors

Constructor Description
(constructor)(props) Constructs a new instance of the PureDataObject class

Static Methods

Method Return Type Description
getDataObject(runtime) Promise<PureDataObject<DataObjectTypes>>

Properties

Property Modifiers Type Description
context IFluidDataStoreContext This context is used to talk up to the ContainerRuntime
disposed boolean
handle IFluidHandle<this> Handle to a data store
id string
IFluidHandle IFluidHandle<this>
IFluidLoadable this
IFluidRouter this
initializeP Promise<void> | undefined
initProps optional I["InitialState"]
providers AsyncFluidObjectProvider<I["OptionalProviders"]>

Providers are FluidObject keyed objects that provide back a promise to the corresponding FluidObject or undefined. Providers injected/provided by the Container and/or HostingApplication

To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store

runtime IFluidDataStoreRuntime This is your FluidDataStoreRuntime object

Methods

Method Return Type Description
dispose() void Called when the host container closes and disposes itself
finishInitialization(existing) Promise<void> Call this API to ensure PureDataObject is fully initialized. Initialization happens on demand, only on as-needed bases. In most cases you should allow factory/object to decide when to finish initialization. But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods and need a fully initialized object, then you can call this API to ensure object is fully initialized.
getFluidObjectFromDirectory(key, directory, getObjectFromDirectory) Promise<T | undefined> Retrieve Fluid object using the handle get
getService(id) Promise<T> Gets the service at a given id.
hasInitialized() Promise<void> Called every time the data store is initialized after create or existing.
initializeInternal(existing) Promise<void>

Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should generally not be done.

Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is responsible for ensuring this is only invoked once.

initializingFirstTime(props) Promise<void> Called the first time the data store is initialized (new creations with a new data store runtime)
initializingFromExisting() Promise<void> Called every time but the first time the data store is initialized (creations with an existing data store runtime)
preInitialize() Promise<void> Called every time the data store is initialized, before initializingFirstTime or initializingFromExisting is called.
request(req) Promise<IResponse> Return this object if someone requests it directly We will return this object in two scenarios: 1. the request url is a "/" 2. the request url is empty

Constructor Details

(constructor)

Constructs a new instance of the PureDataObject class

Signature

constructor(props: IDataObjectProps<I>);

Parameters

Parameter Type Description
props IDataObjectProps<I>

Property Details

context

This context is used to talk up to the ContainerRuntime

Signature

protected readonly context: IFluidDataStoreContext;

Type: IFluidDataStoreContext

disposed

Signature

get disposed(): boolean;

Type: boolean

handle

Handle to a data store

Signature

get handle(): IFluidHandle<this>;

Type: IFluidHandle<this>

id

Signature

get id(): string;

Type: string

IFluidHandle

Signature

get IFluidHandle(): IFluidHandle<this>;

Type: IFluidHandle<this>

IFluidLoadable

Signature

get IFluidLoadable(): this;

Type: this

IFluidRouter

Signature

get IFluidRouter(): this;

Type: this

initializeP

Signature

protected initializeP: Promise<void> | undefined;

Type: Promise<void> | undefined

initProps

Signature

protected initProps?: I["InitialState"];

Type: I["InitialState"]

providers

Providers are FluidObject keyed objects that provide back a promise to the corresponding FluidObject or undefined. Providers injected/provided by the Container and/or HostingApplication

To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store

Signature

protected readonly providers: AsyncFluidObjectProvider<I["OptionalProviders"]>;

Type: AsyncFluidObjectProvider<I["OptionalProviders"]>

runtime

This is your FluidDataStoreRuntime object

Signature

protected readonly runtime: IFluidDataStoreRuntime;

Type: IFluidDataStoreRuntime

Method Details

dispose

Called when the host container closes and disposes itself

Signature

dispose(): void;

finishInitialization

Call this API to ensure PureDataObject is fully initialized. Initialization happens on demand, only on as-needed bases. In most cases you should allow factory/object to decide when to finish initialization. But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods and need a fully initialized object, then you can call this API to ensure object is fully initialized.

Signature

finishInitialization(existing: boolean): Promise<void>;

Parameters

Parameter Type Description
existing boolean

Returns

Return type: Promise<void>

getDataObject

Signature

static getDataObject(runtime: IFluidDataStoreRuntime): Promise<PureDataObject<DataObjectTypes>>;

Parameters

Parameter Type Description
runtime IFluidDataStoreRuntime

Returns

Return type: Promise<PureDataObject<DataObjectTypes>>

getFluidObjectFromDirectory

Retrieve Fluid object using the handle get

Signature

getFluidObjectFromDirectory<T extends IFluidLoadable>(key: string, directory: IDirectory, getObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined): Promise<T | undefined>;
Type Parameters
Parameter Constraint Description
T IFluidLoadable

Parameters

Parameter Modifiers Type Description
key string key that object (handle/id) is stored with in the directory
directory IDirectory directory containing the object
getObjectFromDirectory optional (id: string, directory: IDirectory) => IFluidHandle | undefined optional callback for fetching object from the directory, allows users to define custom types/getters for object retrieval

Returns

Return type: Promise<T | undefined>

getService

Gets the service at a given id.

Signature

protected getService<T extends FluidObject>(id: string): Promise<T>;
Type Parameters
Parameter Constraint Description
T FluidObject

Parameters

Parameter Type Description
id string service id

Returns

Return type: Promise<T>

hasInitialized

Called every time the data store is initialized after create or existing.

Signature

protected hasInitialized(): Promise<void>;

Returns

Return type: Promise<void>

initializeInternal

Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should generally not be done.

Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is responsible for ensuring this is only invoked once.

Signature

initializeInternal(existing: boolean): Promise<void>;

Parameters

Parameter Type Description
existing boolean

Returns

Return type: Promise<void>

initializingFirstTime

Called the first time the data store is initialized (new creations with a new data store runtime)

Signature

protected initializingFirstTime(props?: I["InitialState"]): Promise<void>;

Parameters

Parameter Modifiers Type Description
props optional I["InitialState"] Optional props to be passed in on create

Returns

Return type: Promise<void>

initializingFromExisting

Called every time but the first time the data store is initialized (creations with an existing data store runtime)

Signature

protected initializingFromExisting(): Promise<void>;

Returns

Return type: Promise<void>

preInitialize

Called every time the data store is initialized, before initializingFirstTime or initializingFromExisting is called.

Signature

protected preInitialize(): Promise<void>;

Returns

Return type: Promise<void>

request

Return this object if someone requests it directly We will return this object in two scenarios: 1. the request url is a "/" 2. the request url is empty

Signature

request(req: IRequest): Promise<IResponse>;

Parameters

Parameter Type Description
req IRequest

Returns

Return type: Promise<IResponse>