PureDataObjectFactory Class
Packages > @fluidframework/aqueduct > PureDataObjectFactory
PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject. Consumers should typically use DataObjectFactory instead unless creating another base data store factory.
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
Signature:
export declare class PureDataObjectFactory<TObj extends PureDataObject<P, S>, P, S> implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>
Implements: IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(type, ctor, sharedObjects, optionalProviders, registryEntries, onDemandInstantiation) | Constructs a new instance of the PureDataObjectFactory class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
IFluidDataStoreFactory | this | ||
IFluidDataStoreRegistry | IFluidDataStoreRegistry | undefined | ||
registryEntry | NamedFluidDataStoreRegistryEntry | 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. | |
type | string |
Methods
Method | Modifiers | Description |
---|---|---|
buildRegistryPath(context) | Takes context, and creates package path for a sub-entry (represented by factory in context registry). Package path returned is used to reach given factory from root (container runtime) registry, and thus is used to serialize and de-serialize data store that this factory would create. Function validates that given factory is present in registry, otherwise it throws. | |
createChildInstance(parentContext, initialState) | 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) | 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(containerRuntime, packagePath, initialState) | ||
createPeerInstance(peerContext, initialState) | 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. | |
instantiateDataStore(context) | This is where we do data store setup. | |
instantiateDataStoreCore(context, props) | Private method for data store instantiation that exposes initial state |
Constructors
PureDataObjectFactory.(constructor)
Constructs a new instance of the PureDataObjectFactory
class
Signature:
constructor(type: string, ctor: new (props: IDataObjectProps<P>) => TObj, sharedObjects: readonly IChannelFactory[], optionalProviders: FluidObjectSymbolProvider<P>, registryEntries?: NamedFluidDataStoreRegistryEntries, onDemandInstantiation?: boolean);
Parameters
Parameter | Type | Description |
---|---|---|
type | string | |
ctor | new (props: IDataObjectProps ) => TObj |
|
sharedObjects | readonly IChannelFactory[] | |
optionalProviders | FluidObjectSymbolProvider | |
registryEntries | NamedFluidDataStoreRegistryEntries | |
onDemandInstantiation | boolean |
Properties
IFluidDataStoreFactory
Signature:
get IFluidDataStoreFactory(): this;
IFluidDataStoreRegistry
Signature:
get IFluidDataStoreRegistry(): 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
Signature:
readonly type: string;
Methods
buildRegistryPath
Takes context, and creates package path for a sub-entry (represented by factory in context registry). Package path returned is used to reach given factory from root (container runtime) registry, and thus is used to serialize and de-serialize data store that this factory would create. Function validates that given factory is present in registry, otherwise it throws.
Signature:
protected buildRegistryPath(context: IFluidDataStoreContext | IContainerRuntimeBase): string[];
Parameters
Parameter | Type | Description |
---|---|---|
context | IFluidDataStoreContext | IContainerRuntimeBase |
Returns:
string[]
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?: S): Promise<TObj>;
Parameters
Parameter | Type | Description |
---|---|---|
parentContext | IFluidDataStoreContext | |
initialState | S | The initial state to provide to the created data store. |
Returns:
Promise<TObj>
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.
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?: S): Promise<TObj>;
Parameters
Parameter | Type | Description |
---|---|---|
runtime | IContainerRuntimeBase | container runtime. It's registry is used to create an object. |
initialState | S | The initial state to provide to the created component. |
Returns:
Promise<TObj>
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.
createInstanceCore
Signature:
protected createInstanceCore(containerRuntime: IContainerRuntimeBase, packagePath: Readonly<string[]>, initialState?: S): Promise<TObj>;
Parameters
Parameter | Type | Description |
---|---|---|
containerRuntime | IContainerRuntimeBase | |
packagePath | Readonly |
|
initialState | S |
Returns:
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?: S): Promise<TObj>;
Parameters
Parameter | Type | Description |
---|---|---|
peerContext | IFluidDataStoreContext | |
initialState | S | The initial state to provide to the created component. |
Returns:
Promise<TObj>
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.
instantiateDataStore
This is where we do data store setup.
Signature:
instantiateDataStore(context: IFluidDataStoreContext): Promise<FluidDataStoreRuntime>;
Parameters
Parameter | Type | Description |
---|---|---|
context | IFluidDataStoreContext | data store context used to load a data store runtime |
Returns:
Promise<FluidDataStoreRuntime>
instantiateDataStoreCore
Private method for data store instantiation that exposes initial state
Signature:
protected instantiateDataStoreCore(context: IFluidDataStoreContext, props?: S): FluidDataStoreRuntime;
Parameters
Parameter | Type | Description |
---|---|---|
context | IFluidDataStoreContext | data store context used to load a data store runtime |
props | S |
Returns: