PureDataObject Class

Packages > @fluidframework/aqueduct > PureDataObject

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

Generics: O - represents a type that will define optional providers that will be injected S - the initial state type that the produced data store may take during creation E - represents events that will be available in the EventForwarder

Signature:

export declare abstract class PureDataObject<O extends IFluidObject = object, S = undefined, E extends IEvent = IEvent> extends EventForwarder<E> implements IFluidLoadable, IFluidRouter, IProvideFluidHandle, IFluidObject 

Extends: EventForwarder<E>

Implements: IFluidLoadable, IFluidRouter, IProvideFluidHandle, IFluidObject

Constructors

List of constructors for this class
Constructor Modifiers Description
(constructor)(props) Constructs a new instance of the PureDataObject class

Properties

List of properties for this class
Property Modifiers Type Description
context IFluidDataStoreContext This context is used to talk up to the ContainerRuntime
disposed boolean
handle IFluidHandle Handle to a data store
id string
IFluidHandle IFluidHandle
IFluidLoadable this
IFluidRouter this
initializeP Promise | undefined
initProps S
providers AsyncFluidObjectProvider<FluidObjectKey, FluidObjectKey> Providers are IFluidObject keyed objects that provide back a promise to the corresponding IFluidObject or undefined. Providers injected/provided by the Container and/or HostingApplicationTo define providers set IFluidObject interfaces in the generic O type for your data store
runtime IFluidDataStoreRuntime This is your FluidDataStoreRuntime object

Methods

List of methods on this class
Method Modifiers Description
dispose() Called when the host container closes and disposes itself
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 fully initialized object, then you can call this API to ensure object is fully initialized.
getDataObject(runtime) static
getFluidObjectFromDirectory(key, directory, getObjectFromDirectory) Retreive Fluid object using the handle get or the older requestFluidObject_UNSAFE call to fetch by ID
getService(id) Gets the service at a given id.
hasInitialized() Called every time the data store is initialized after create or existing.
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.
initializingFirstTime(props) Called the first time the data store is initialized (new creations with a new data store runtime)
initializingFromExisting() Called every time but the first time the data store is initialized (creations with an existing data store runtime)
preInitialize() Called every time the data store is initialized, before initializingFirstTime or initializingFromExisting is called.
request(req) 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
requestFluidObject_UNSAFE(id)

Constructors

PureDataObject.(constructor)

Constructs a new instance of the PureDataObject class

Signature:

constructor(props: IDataObjectProps<O, S>);

Parameters

List of parameters
Parameter Type Description
props IDataObjectProps

Properties

context

This context is used to talk up to the ContainerRuntime

Signature:

protected readonly context: IFluidDataStoreContext;

disposed

Signature:

get disposed(): boolean;

handle

Handle to a data store

Signature:

get handle(): IFluidHandle<this>;

id

Signature:

get id(): string;

IFluidHandle

Signature:

get IFluidHandle(): IFluidHandle<this>;

IFluidLoadable

Signature:

get IFluidLoadable(): this;

IFluidRouter

Signature:

get IFluidRouter(): this;

initializeP

Signature:

protected initializeP: Promise<void> | undefined;

initProps

Signature:

protected initProps?: S;

providers

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

To define providers set IFluidObject interfaces in the generic O type for your data store

Signature:

protected readonly providers: AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<object>>;

runtime

This is your FluidDataStoreRuntime object

Signature:

protected readonly runtime: IFluidDataStoreRuntime;

Methods

dispose

Called when the host container closes and disposes itself

Signature:

dispose(): void;

Returns:

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 fully initialized object, then you can call this API to ensure object is fully initialized.

Signature:

finishInitialization(): Promise<void>;

Returns:

Promise<void>

getDataObject

Signature:

static getDataObject(runtime: IFluidDataStoreRuntime): Promise<PureDataObject<object, undefined, IEvent>>;

Parameters

List of parameters
Parameter Type Description
runtime IFluidDataStoreRuntime

Returns:

Promise<PureDataObject<object, undefined, IEvent>>

getFluidObjectFromDirectory

Retreive Fluid object using the handle get or the older requestFluidObject_UNSAFE call to fetch by ID

Signature:

getFluidObjectFromDirectory<T extends IFluidObject & IFluidLoadable>(key: string, directory: IDirectory, getObjectFromDirectory?: (id: string, directory: IDirectory) => string | IFluidHandle | undefined): Promise<T | undefined>;

Parameters

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

Returns:

Promise<T | undefined>

getService

Gets the service at a given id.

Signature:

protected getService<T extends IFluidObject>(id: string): Promise<T>;

Parameters

List of parameters
Parameter Type Description
id string service id

Returns:

Promise<T>

hasInitialized

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

Signature:

protected hasInitialized(): Promise<void>;

Returns:

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(): Promise<void>;

Returns:

Promise<void>

initializingFirstTime

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

Signature:

protected initializingFirstTime(props?: S): Promise<void>;

Parameters

List of parameters
Parameter Type Description
props S Optional props to be passed in on create

Returns:

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:

Promise<void>

preInitialize

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

Signature:

protected preInitialize(): Promise<void>;

Returns:

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

List of parameters
Parameter Type Description
req IRequest

Returns:

Promise<IResponse>

requestFluidObject_UNSAFE

Warning: This API is now obsolete.

Gets the data store of a given id. Will follow the pattern of the container for waiting.

Signature:

protected requestFluidObject_UNSAFE<T extends IFluidObject>(id: string): Promise<T>;

Parameters

List of parameters
Parameter Type Description
id string data store id

Returns:

Promise<T>