Skip to content

Comments

feat(angular): add convenience value method alongside details method in generated service#228

Open
tomflenner wants to merge 2 commits intoopen-feature:mainfrom
tomflenner:226-feat-generate-convenience-method-value-only
Open

feat(angular): add convenience value method alongside details method in generated service#228
tomflenner wants to merge 2 commits intoopen-feature:mainfrom
tomflenner:226-feat-generate-convenience-method-value-only

Conversation

@tomflenner
Copy link
Contributor

This PR

Adds a new convenience method in the generated Angular service that directly returns an Observable<T> of the flag value, in addition to the existing get<FlagName>Details method returning Observable<EvaluationDetails<T>>.

Today, the generator produces:

getMySuperFeatureDetails(
  domain?: string,
  options?: AngularFlagEvaluationOptions
): Observable<EvaluationDetails<boolean>> {
  return this.flagService.getBooleanDetails(
    "my-super-feature",
    true,
    domain,
    {
      updateOnConfigurationChanged: options?.updateOnConfigurationChanged ?? true,
      updateOnContextChanged: options?.updateOnContextChanged ?? true,
    }
  );
}

In most modern Angular applications (especially when using Signals), consumers are primarily interested in the flag value:

private mySuperFeatureEnabled = toSignal(
  this.featureFlagService
    .getMySuperFeatureDetails()
    .pipe(map((details) => details.value))
);

This PR adds a generated convenience method:

getMySuperFeature(
  domain?: string,
  options?: AngularFlagEvaluationOptions
): Observable<boolean> {
  return this.getMySuperFeatureDetails(domain, options).pipe(
    map((details) => details.value)
  );
}

This allows a simpler usage:

private mySuperFeatureEnabled = toSignal(
  this.featureFlagService.getMySuperFeature()
);
  • adds a new generated convenience method returning Observable<T>
  • reduces repetitive .pipe(map(details => details.value)) boilerplate
  • aligns Angular generator behavior with the C# generator
  • improves developer ergonomics for common use cases

Related Issues

Fixes #226

Notes

This is a non-breaking, additive feature.

The existing get<FlagName>Details method remains unchanged to preserve access to full EvaluationDetails when needed.

How to test

  1. Run the integration test suite using make test-integration
  2. Generate Angular code from a sample configuration:
openfeature generate angular -i path/to/manifest.json -o output/directory

@tomflenner tomflenner force-pushed the 226-feat-generate-convenience-method-value-only branch from a881233 to 3c86e7c Compare February 23, 2026 14:17
…in generated service

Signed-off-by: backtrack5r3 <flennertom@gmail.com>
@tomflenner tomflenner force-pushed the 226-feat-generate-convenience-method-value-only branch from 3c86e7c to 5cb9dbe Compare February 23, 2026 14:17
@gemini-code-assist
Copy link

Summary of Changes

Hello @tomflenner, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the generated Angular service by adding a convenience method for retrieving flag values directly as Observables. This simplifies common use cases, reduces boilerplate, and aligns the Angular generator with the C# generator, improving developer ergonomics.

Highlights

  • New Convenience Method: Introduces a new method in the generated Angular service that directly returns an Observable<T> of the flag value, complementing the existing get<FlagName>Details method.
  • Simplified Usage: Reduces boilerplate code by eliminating the need for .pipe(map(details => details.value)) when consumers primarily need the flag value.
  • Alignment with C# Generator: Ensures consistency across different language generators by aligning the Angular generator behavior with the C# generator.
Changelog
  • internal/cmd/testdata/success_angular.golden
    • Added new convenience methods for retrieving flag values directly as Observables.
  • internal/generators/angular/angular.tmpl
    • Added template logic to generate the new convenience methods in the Angular service.
  • test/angular-integration/specs/service.spec.ts
    • Added integration tests to verify the functionality of the new convenience methods.
Activity
  • The PR introduces a new convenience method in the generated Angular service.
  • The existing get<FlagName>Details method remains unchanged to preserve access to full EvaluationDetails when needed.
  • Integration tests were added to verify the new functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces convenience methods to the generated Angular service, allowing direct access to flag values as Observable<T> instead of Observable<EvaluationDetails<T>>. This improves developer ergonomics by reducing boilerplate. The changes include adding map operator imports and generating new methods that pipe the existing Details methods to extract the value property. New integration tests have also been added to cover these convenience methods.

The rxjs docs gives best practices : https://rxjs.dev/guide/importing#new-in-rxjs-v720

Signed-off-by: backtrack5r3 <flennertom@gmail.com>
@tomflenner tomflenner force-pushed the 226-feat-generate-convenience-method-value-only branch from 24215a3 to 61c9536 Compare February 23, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(angular): generate convenience method returning flag value Observable

1 participant