Skip to main content
Version: v1

PureDataObjectFactory Class

PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject. Consumers should typically use DataObjectFactory instead unless creating another base data store factory.

Signature​

export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends DataObjectTypes = DataObjectTypes> implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>, IRootDataObjectFactory

Implements: IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>, IRootDataObjectFactory

Type Parameters​

ParameterConstraintDefaultDescription
TObjPureDataObject<I>DataObject (concrete type)
IDataObjectTypesDataObjectTypesThe input types for the DataObject

Constructors​

ConstructorDescription
(constructor)(type, ctor, sharedObjects, optionalProviders, registryEntries, runtimeClass)Constructs a new instance of the PureDataObjectFactory class

Properties​

PropertyTypeDescription
IFluidDataStoreFactorythis
IFluidDataStoreRegistryIFluidDataStoreRegistry | undefined
registryEntryNamedFluidDataStoreRegistryEntryConvenience helper to get the data store's/factory's data store registry entry. The return type hides the factory's generics, easing grouping of registry entries that differ only in this way into the same array.
typestring

Methods​

MethodReturn TypeDescription
createChildInstance(parentContext, initialState)Promise<TObj>Creates a new instance of the object. Uses parent context's registry to build package path to this factory. In other words, registry of context passed in has to contain this factory, with the name that matches this factory's type. It is intended to be used by data store objects that create sub-objects.
createInstance(runtime, initialState)Promise<TObj>Creates a new instance of the object. Uses container's registry to find this factory. It's expected that only container owners would use this functionality, as only such developers have knowledge of entries in container registry. The name in this registry for such record should match type of this factory.
createInstanceCore(context, initialState)Promise<TObj>
createNonRootInstanceCore(containerRuntime, packagePath, initialState)Promise<TObj>
createPeerInstance(peerContext, initialState)Promise<TObj>Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory. In other words, registry of context passed in has to have this factory. Intended to be used by data store objects that need to create peers (similar) instances of existing objects.
createRootInstance(rootDataStoreId, runtime, initialState)Promise<TObj>Creates a new root instance of the object. Uses container's registry to find this factory. It's expected that only container owners would use this functionality, as only such developers have knowledge of entries in container registry. The name in this registry for such record should match type of this factory.
instantiateDataStore(context, existing)Promise<FluidDataStoreRuntime>This is where we do data store setup.

Constructor Details​

(constructor)​

Constructs a new instance of the PureDataObjectFactory class

Signature​

constructor(type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory[], optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeClass?: typeof FluidDataStoreRuntime);

Parameters​

ParameterModifiersTypeDescription
typestring
ctornew (props: IDataObjectProps<I>) => TObj
sharedObjectsreadonly IChannelFactory[]
optionalProvidersFluidObjectSymbolProvider<I["OptionalProviders"]>
registryEntriesoptionalNamedFluidDataStoreRegistryEntries
runtimeClassoptionaltypeof FluidDataStoreRuntime

Property Details​

IFluidDataStoreFactory​

Signature​

get IFluidDataStoreFactory(): this;

Type: this

IFluidDataStoreRegistry​

Signature​

get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined;

Type: IFluidDataStoreRegistry | undefined

registryEntry​

Convenience helper to get the data store's/factory's data store registry entry. The return type hides the factory's generics, easing grouping of registry entries that differ only in this way into the same array.

Signature​

get registryEntry(): NamedFluidDataStoreRegistryEntry;

Type: NamedFluidDataStoreRegistryEntry

type​

Signature​

readonly type: string;

Type: string

Method Details​

createChildInstance​

Creates a new instance of the object. Uses parent context's registry to build package path to this factory. In other words, registry of context passed in has to contain this factory, with the name that matches this factory's type. It is intended to be used by data store objects that create sub-objects.

Signature​

createChildInstance(parentContext: IFluidDataStoreContext, initialState?: I["InitialState"]): Promise<TObj>;

Parameters​

ParameterModifiersTypeDescription
parentContextIFluidDataStoreContext
initialStateoptionalI["InitialState"]The initial state to provide to the created data store.

Returns​

an object created by this factory. Data store and objects created are not attached to container. They get attached only when a handle to one of them is attached to already attached objects.

Return type: Promise<TObj>

createInstance​

Creates a new instance of the object. Uses container's registry to find this factory. It's expected that only container owners would use this functionality, as only such developers have knowledge of entries in container registry. The name in this registry for such record should match type of this factory.

Signature​

createInstance(runtime: IContainerRuntimeBase, initialState?: I["InitialState"]): Promise<TObj>;

Parameters​

ParameterModifiersTypeDescription
runtimeIContainerRuntimeBasecontainer runtime. It's registry is used to create an object.
initialStateoptionalI["InitialState"]The initial state to provide to the created component.

Returns​

an object created by this factory. Data store and objects created are not attached to container. They get attached only when a handle to one of them is attached to already attached objects.

Return type: Promise<TObj>

createInstanceCore​

Signature​

protected createInstanceCore(context: IFluidDataStoreContextDetached, initialState?: I["InitialState"]): Promise<TObj>;

Parameters​

ParameterModifiersTypeDescription
contextIFluidDataStoreContextDetached
initialStateoptionalI["InitialState"]

Returns​

Return type: Promise<TObj>

createNonRootInstanceCore​

Signature​

protected createNonRootInstanceCore(containerRuntime: IContainerRuntimeBase, packagePath: Readonly<string[]>, initialState?: I["InitialState"]): Promise<TObj>;

Parameters​

ParameterModifiersTypeDescription
containerRuntimeIContainerRuntimeBase
packagePathReadonly<string[]>
initialStateoptionalI["InitialState"]

Returns​

Return type: Promise<TObj>

createPeerInstance​

Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory. In other words, registry of context passed in has to have this factory. Intended to be used by data store objects that need to create peers (similar) instances of existing objects.

Signature​

createPeerInstance(peerContext: IFluidDataStoreContext, initialState?: I["InitialState"]): Promise<TObj>;

Parameters​

ParameterModifiersTypeDescription
peerContextIFluidDataStoreContext
initialStateoptionalI["InitialState"]The initial state to provide to the created component.

Returns​

an object created by this factory. Data store and objects created are not attached to container. They get attached only when a handle to one of them is attached to already attached objects.

Return type: Promise<TObj>

createRootInstance​

Creates a new root instance of the object. Uses container's registry to find this factory. It's expected that only container owners would use this functionality, as only such developers have knowledge of entries in container registry. The name in this registry for such record should match type of this factory.

Signature​

createRootInstance(rootDataStoreId: string, runtime: IContainerRuntime, initialState?: I["InitialState"]): Promise<TObj>;

Parameters​

ParameterModifiersTypeDescription
rootDataStoreIdstring
runtimeIContainerRuntimecontainer runtime. It's registry is used to create an object.
initialStateoptionalI["InitialState"]The initial state to provide to the created component.

Returns​

an object created by this factory. Data store and objects created are not attached to container. They get attached only when a handle to one of them is attached to already attached objects.

Return type: Promise<TObj>

instantiateDataStore​

This is where we do data store setup.

Signature​

instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;

Parameters​

ParameterTypeDescription
contextIFluidDataStoreContextdata store context used to load a data store runtime
existingboolean

Returns​

Return type: Promise<FluidDataStoreRuntime>