-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lock down ways to instantiate a DDS #1845
Comments
FluidDataStoreRuntime.createChannel() seems like the other (right?) way to create DDS, though it lacks type safety. |
Here is what I think the world looks like (using SharedMap as an example):
We do want to push people toward # 3 pattern - this story still is in progress for data stores, but it was always the case for DDS, so it's good. So I think the only interesting tidbit is # 1 - usage of factories. I do not see how your proposal will play out, given typical code we write looks like that: export class Clicker extends DataObject implements IFluidHTMLView {
private static readonly factory = new DataObjectFactory<Clicker, undefined, undefined, IEvent>(
Clicker.ComponentName,
Clicker,
[
SharedCounter.getFactory(),
SharedMap.getFactory(),
],
{});
} I do not think the following is better - it takes more effort to track things as they are now in two different places: const dataTypes = new SharedObjectRegistry();
SharedCounter.registerFactory(dataTypes);
SharedMap.registerFactory(dataTypes),
....
export class Clicker extends DataObject implements IFluidHTMLView {
private static readonly factory = new DataObjectFactory<Clicker, undefined, undefined, IEvent>(
Clicker.ComponentName,
Clicker,
dataTypes,
{});
} I'd suggest to do nothing here (i.e. punt this issue) and wait for #3469 (Unification of channels) to eventually change this area. |
This issue has been automatically marked as stale because it has had no activity for 180 days. It will be closed if no further activity occurs within 8 days of this comment. Thank you for your contributions to Fluid Framework! |
@vladsud / @ChumpChief - Worth keeping open and investing in? I don't have much depth of knowledge in this space, it was just something I noticed while exploring the code early on. |
This issue has been automatically marked as stale because it has had no activity for 180 days. It will be closed if no further activity occurs within 8 days of this comment. Thank you for your contributions to Fluid Framework! |
Feature
Is your feature request related to a problem? Please describe.
Looking at the code for several DDS's, I'm seeing a pattern where these 3 are exposed publicly:
There are clear patterns of use, but for a new dev walking up to these classes, it's confusing what you're supposed to do.
Describe the solution you'd like
It seems that the only one that should be exposed publicly is
public static create
.The
constructor
should only be callable by the Factory, but I'm not sure how to actually implement this in TypeScript.As for
getFactory
, a few ideas:SharedMap.getFactory()
withnew MapFactory()
)getFactory
withregisterFactory
which takes in a function (2a) or type (2b) that can take the factory and do the right thing with it - without exposing a trivial way to get the factory returned.2a. Define a type/interface like this:
type FactoryRegistrar = (factory: ISharedObjectFactory) => void;
thenregisterFactory
is:And callers become:
2b. Add
register(factory: ISharedObjectFactory);
toISharedObjectRegistry
and provide a class that implements it like this:Then callers look like this:
The text was updated successfully, but these errors were encountered: