Remove all uses of getComponent to fetch by id
- Remove all uses of getComponent
- Updated _scheduler to also be a PrimedComponent for which we can store and retrieve the component by handle
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?
Why is it an requirement to be
PrimedComponentbefore 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,
PrimedComponentis part of theframeworklayer, and_schedule(oragent-scheduler) is part of the system component, that belongs to theruntimelayer. Theruntimelayer shouldn't take dependency to theframeworklayer?
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.
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).
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