-
Notifications
You must be signed in to change notification settings - Fork 396
allow using lazy loadable renderers in angular #2446
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
base: master
Are you sure you want to change the base?
Changes from all commits
4c58e98
13a6223
22c2af3
3f5b96f
0db28a5
bd4f68a
a32e454
5e32b15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
*/ | ||
import maxBy from 'lodash/maxBy'; | ||
import { | ||
ComponentFactory, | ||
ComponentFactoryResolver, | ||
Directive, | ||
Input, | ||
|
@@ -126,11 +127,32 @@ export class JsonFormsOutlet | |
renderer !== undefined && | ||
renderer.tester(uischema, schema, testerContext) !== -1 | ||
) { | ||
bestComponent = renderer.renderer; | ||
if (renderer.renderer instanceof Promise) { | ||
renderer.renderer.then((resolvedRenderer) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also think about storing the resolved component somewhere, maybe even in the registry entry. This would be useful so that once a renderer is resolved, we avoid the whole "LoadingSpinner" code path the next time it is invoked. |
||
bestComponent = resolvedRenderer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assignment points to a code smell:
|
||
const componentFactory = | ||
this.componentFactoryResolver.resolveComponentFactory( | ||
bestComponent | ||
); | ||
this.renderComponent(componentFactory, uischema, schema, props); | ||
}); | ||
return; | ||
} else { | ||
bestComponent = renderer.renderer; | ||
} | ||
} | ||
|
||
const componentFactory = | ||
this.componentFactoryResolver.resolveComponentFactory(bestComponent); | ||
this.renderComponent(componentFactory, uischema, schema, props); | ||
Comment on lines
145
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For async components, this will lead to the |
||
} | ||
|
||
private renderComponent( | ||
componentFactory: ComponentFactory<any>, | ||
uischema: UISchemaElement, | ||
schema: JsonSchema, | ||
props: JsonFormsProps | ||
) { | ||
this.viewContainerRef.clear(); | ||
const currentComponentRef = | ||
this.viewContainerRef.createComponent(componentFactory); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be a race condition here: