Skip to content
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

Deprecate/remove context/runtime component creation patterns and update examples #1537

Closed
heliocliu opened this issue Mar 17, 2020 · 2 comments
Assignees
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct
Milestone

Comments

@heliocliu
Copy link
Contributor

See #777
Once IComponentFactory is set up to create components, we need to deprecate the old methods of creating components through the runtime/context, and update our examples to use the new method.

@heliocliu heliocliu added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Mar 17, 2020
@heliocliu heliocliu self-assigned this Mar 17, 2020
@curtisman curtisman added this to the April 2020 milestone Mar 23, 2020
@heliocliu heliocliu changed the title Deprecate context/runtime component creation patterns and update examples Deprecate/remove context/runtime component creation patterns and update examples Apr 12, 2020
@heliocliu heliocliu modified the milestones: April 2020, May 2020 Apr 12, 2020
heliocliu added a commit that referenced this issue Apr 24, 2020
…mples (#1833)

Addresses #1537

Started out as updating components that used the old props flow to create components with initial state, but copypasting the changes from Clicker got tedious and I got templates on the factories to work in a way that needs much less boilerplate from the component developer. This involves providing template types to Shared/PrimedComponentFactory for the component class and the initial state class. The IComponentFactory is unchanged, so it still requires a reference to the specific component factory to create with initial state, while the specific instance of the component factory will require strongly typed input. Additionally, component developers only need to provide a custom ctor that takes the initial state, and provide the appropriate types when creating the factory. I think the template type for the component class in the factory is actually unnecessary here, but Skyler is adding it separately it seems and I'll need to reconcile it once that change is in.

This also results in the issue where trying to put multiple tempalted ComponentFactories into a registry map leads to type conflicts, so I also added a registryEntry property that provides the factories as a consistent, more generic type (and also results in slightly shorter registry specifications).

* initial commit

Try adding some generics to the component factories to reduce the amount of boilerplate code that components need to provide in order to hook into using initial state creation.  This may interfere with the other generics being added for typed events and component providers, will need to be resolved.  Also add a registryEntry property for the factories that types the factory to the lowest common denominator generic types, because ts doesn't infer this when mixing factories with generics.

Update a few examples

* remove remaining uses of props

Remove remaining uses of props in componentInitializingFirstTime (the remaining occurences weren't actually using them 🤷)

* Remove component type generic

Remove component type template because it is not necessary, and because the typed event emitter and component provider changes add templates as well.  Having unnecessary templating makes the code harder to understand than necessary.

* fix additional merge issues

fix additional merge issues that did not show as conflicts with the synthesizer change

* fix todo tests

fix circular import with TodoItem and TodoItemInstantiationFactory
fix additional todoitem component creation calls to use new initial state path

* add initial state templating to Shared/PrimedComponent

Add the initial state templating to Shared/PrimedComponent
This lets the component strongly type the initial state without having to redeclare the component ctor with the specific type, and not have to store the initial state object as a member temporarily.

* iteration updates

Update some comments and add an entry into breaking.md
Move all templating to the component from the factory (providing in one place allows ts to infer in the other, and we want it to be defined in the component)

* iteration changes

use new methods of getting component type and factory registry entries in touched files
update readme to include info on new way to create components and provide initial state
@curtisman curtisman modified the milestones: May 2020, June 2020 Jun 1, 2020
@heliocliu
Copy link
Contributor Author

Blocked by #1756; runtime's createComponent's remaining usages cannot be removed because it supports getting the default component by id (e.g. during initial creation, where the request handler for the default component gets the runtime by id). This could be probably be fixed by saving a reference to the default component specifically, but once 1756 is fixed it may end up getting changed again anyway. Same with ComponentContext's createComponent, which allows the caller to specify an id, and the current users are using that id through the request infra instead of through handles

@heliocliu
Copy link
Contributor Author

vlad is changing these paths in a different way from this originally in his work eg #2950 #2951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct
Projects
None yet
Development

No branches or pull requests

2 participants