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​

ParameterConstraintDefaultDescription
IDataObjectTypesDataObjectTypesThe optional input types used to strongly type the data object

Constructors​

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

Static Methods​

MethodReturn TypeDescription
getDataObject(runtime)Promise<PureDataObject<DataObjectTypes>>

Properties​

PropertyModifiersTypeDescription
contextIFluidDataStoreContextThis context is used to talk up to the ContainerRuntime
disposedboolean
handleIFluidHandle<this>Handle to a data store
idstring
IFluidHandleIFluidHandle<this>
IFluidLoadablethis
IFluidRouterthis
initializePPromise<void> | undefined
initPropsoptionalI["InitialState"]
providersAsyncFluidObjectProvider<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

runtimeIFluidDataStoreRuntimeThis is your FluidDataStoreRuntime object

Methods​

MethodReturn TypeDescription
dispose()voidCalled 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​

ParameterTypeDescription
propsIDataObjectProps<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​

ParameterTypeDescription
existingboolean

Returns​

Return type: Promise<void>

getDataObject​

Signature​

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

Parameters​

ParameterTypeDescription
runtimeIFluidDataStoreRuntime

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​
ParameterConstraintDescription
TIFluidLoadable

Parameters​

ParameterModifiersTypeDescription
keystringkey that object (handle/id) is stored with in the directory
directoryIDirectorydirectory containing the object
getObjectFromDirectoryoptional(id: string, directory: IDirectory) => IFluidHandle | undefinedoptional 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​
ParameterConstraintDescription
TFluidObject

Parameters​

ParameterTypeDescription
idstringservice 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​

ParameterTypeDescription
existingboolean

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​

ParameterModifiersTypeDescription
propsoptionalI["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​

ParameterTypeDescription
reqIRequest

Returns​

Return type: Promise<IResponse>