feat(angular): add provideA2Ui helper for idiomatic renderer configuration#2061
feat(angular): add provideA2Ui helper for idiomatic renderer configuration#2061josemontespg wants to merge 6 commits into
Conversation
josemontespg
left a comment
There was a problem hiding this comment.
Adversarial Reviewer Objections:
-
Missing Documentation Update: The setup guide
docs/public/guides/client-setup.mdstill shows the verbose setup usingA2UI_RENDERER_CONFIGdirectly. It should be updated to use the newprovideA2Uihelper. -
Inflexible API (Suggestion): The
provideA2Uihelper inrenderers/angular/src/v0_9/core/a2ui-renderer.service.tsonly supports static configuration values (useValue). In many real-world scenarios (like in therestaurantsample), the configuration requires injecting other services (e.g., to handle actions).
To make provideA2Ui more versatile, please consider supporting factory functions:
export function provideA2Ui(
configOrFactory: RendererConfiguration | (() => RendererConfiguration)
): EnvironmentProviders {
return makeEnvironmentProviders([
{
provide: A2UI_RENDERER_CONFIG,
...(typeof configOrFactory === 'function'
? { useFactory: configOrFactory }
: { useValue: configOrFactory }),
},
]);
}This will allow us to clean up the samples as well.
There was a problem hiding this comment.
Code Review
This pull request introduces the provideA2Ui helper function to configure the A2UI renderer using Angular's environment providers, along with corresponding unit tests. The feedback suggests enhancing the unit tests to verify that A2uiRendererService can be successfully resolved and instantiated when using this provider helper, ensuring a more robust integration test.
josemontespg
left a comment
There was a problem hiding this comment.
Adversarial review passed. The implementation matches the approved design and successfully simplifies the configuration API while maintaining backward compatibility. Tests passed. (Note: Unable to approve via API as it is detected as own PR)
Also ignore untracked agent files in prettier.
ditman
left a comment
There was a problem hiding this comment.
I like this very much, thanks for tackling it so quickly!
What
Introduces the
provideA2Uihelper function to configure the root A2UI settings using Angular's standalone APIs (EnvironmentProviders,makeEnvironmentProviders).It also updates the
A2uiRendererServiceunit tests to use this new helper.Why
Improves developer experience by replacing verbose provider configurations with a single, clean function call, aligning with modern, idiomatic Angular 14+ patterns.
Resolves: #2003
Effect
Allows configuring A2UI in
bootstrapApplicationlike this:It is 100% backwards compatible as the manual token provision continues to function.