Skip to content 

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: P - 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<P extends IFluidObject = object, S = undefined, E extends IEvent = IEvent> extends EventForwarder<E> implements IFluidLoadable, IFluidRouter, IProvideFluidHandle 

Extends: EventForwarder<E>

Implements: IFluidLoadable, IFluidRouter, IProvideFluidHandle

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
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
url string Absolute URL to the data store within the document

Methods

List of methods on this class
Method Modifiers Description
dispose() Called when the host container closes and disposes itself
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(props) 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)
request(req) Return this object if someone requests it directly We will return this object in three scenarios 1. the request url is a "/" 2. the request url is our url 3. the request url is empty
requestFluidObject_UNSAFE(id)

Constructors

PureDataObject.(constructor)

Constructs a new instance of the PureDataObject class

Signature:

constructor(props: IDataObjectProps<P>);

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;

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<P>, FluidObjectKey<object>>;

runtime

This is your FluidDataStoreRuntime object

Signature:

protected readonly runtime: IFluidDataStoreRuntime;

url

Absolute URL to the data store within the document

Signature:

get url(): string;

Methods

dispose

Called when the host container closes and disposes itself

Signature:

dispose(): void;

Returns:

void

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

Parameters

List of parameters
Parameter Type Description
props S

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>

request

Return this object if someone requests it directly We will return this object in three scenarios 1. the request url is a “/” 2. the request url is our url 3. 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>