FluidFramework icon indicating copy to clipboard operation
FluidFramework copied to clipboard

Remove all uses of getComponent to fetch by id

Open sumedhb1995 opened this issue 6 years ago • 4 comments

  • Remove all uses of getComponent
  • Updated _scheduler to also be a PrimedComponent for which we can store and retrieve the component by handle

sumedhb1995 avatar Mar 25 '20 20:03 sumedhb1995

Why is it an requirement to be PrimedComponent before it can have a handle? I am not sure that should be the case, Any fluid component with a component runtime should be able to have a handle.

In addition, PrimedComponent is part of the framework layer, and _schedule (or agent-scheduler) is part of the system component, that belongs to the runtime layer. The runtime layer shouldn't take dependency to the framework layer?

curtisman avatar Mar 26 '20 13:03 curtisman

Why is it an requirement to be PrimedComponent before it can have a handle? I am not sure that should be the case, Any fluid component with a component runtime should be able to have a handle.

In addition, PrimedComponent is part of the framework layer, and _schedule (or agent-scheduler) is part of the system component, that belongs to the runtime layer. The runtime layer shouldn't take dependency to the framework layer?

It's not so much that it needs to be a PrimedComponent for it to have a handle but that it needs to implement the IComponentLoadable interface. And the classes that we have that implement IComponentLoadable and the ones that are generally extended in practice for users to create their own components are SharedComponent and PrimedComponent. So you're absolutely correct, its not a necessity to be a PrimedComponent.

Also, the dependency wasn't for the component itself but for its tests. However, @agarwal-navin had PR that went in yesterday (https://github.com/microsoft/FluidFramework/pull/1723/files#diff-41ec69b062d3b6e4329869fefc8a6cb9) that removes this dependency since agent-scheduler.spec no longer uses testHost (which is removed) and instead has its own getComponent call. I merged this change with my PR for removing the ID from the createAndAttachComponent call. As such, we should be in good shape for removing the getComponent call completely in the next release. I have currently marked it with a @deprecated flag and renamed it to getComponent_UNSAFE to give users a chance to migrate their code forward.

sumedhb1995 avatar Apr 09 '20 17:04 sumedhb1995

TestHost hasn't been removed yet. There are a bunch of tests in out example components that still use it. Also FYI, Sciptor uses TestHost for ScriptorPad and they do call getComponent on it (although not to get the scheduler).

agarwal-navin avatar Apr 09 '20 17:04 agarwal-navin

TestHost's getComponent will actually do a get on the component handle so its fine after pr #1959 . This is to remove getComponent calls to the runtime with an id param

sumedhb1995 avatar Apr 28 '20 18:04 sumedhb1995