-
Notifications
You must be signed in to change notification settings - Fork 33
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
[FEATURE] Angular SDK implementation #976
Comments
Hey @juanparadox great that you started on this! Where is the difference between these two requirements? Do you have an example for the second one?
For the injection I could imagine injecting the client being good enough. We do something similar in the Nest SDK: Maybe we could also add an injection of individual flag values e.g. as an observable? We do something similar with flag value promises in the Nest SDK. But with the static context we could maybe go for flag value observables that update automatically?
In the Nest SDK we do this only on module init, but I think a thin injectable service to provide that functionality could be good. |
Hey!
The main difference is that the second item is not something that the consumer needs to subscribe to, rather, the service just ensures that it's initialized context change handlers which then update the OpenFeature provider's client so that the subscribers receive a new client which now has the newly evaluated values. Basically, the first is just a simple subscription to the Couple of follow-ups for you:
What would that look like for a consumer/subscriber? Something like this?
That update automatically if the context changes? The reason I ask about this clarification is to differentiate for cases where the flag config is set to stream the value vs requiring a context change handler/page or component refresh. |
I found this article that talks about using directives to support feature flags in templates. Overall, the design looks quite nice in my opinion. I could try and reach out to the author if that would be useful.
|
@lukas-reining @juanparadox I think injecting a client is a good idea, but IMO a directive would be a really "Angular-esque" approach. It would be great if we could build one that would support the same sort of built-in re-rendering we have in the React SDK. I think this could be done by subscribing to change events and then marking the component for re-check. Overall, I think and Angular SDK would be highly valuable. Recently our React SDK (just React, not the web SDK!) surpassed the backend JS SDK in downloads. People REALLY want client-side SDKs and I think this one would get a lot of usage. I personally have found that many orgs which use .NET on the backend happen to use Angular on the frontend, and we already have signigicant .NET usage as well. |
Hey @juanparadox,
So this means the first is just for getting the value once? Why do we have to subscribe here? The web SDK is already synchronous so I think a component could e.g. just call The second option would provide is with something like Is this what you meant or did I get it wrong?
I think this would be better done with the directives, this idea was way better.
I think the two options I described in the top handle these two cases. |
@beeme1mr @toddbaert the directive is a great idea! What do you think @juanparadox? |
That post is super helpful @lukas-reining . I think it's a great starting point. |
I totally think so too @toddbaert! |
@lukas-reining The automatic rerender directive sounds awesome and would actually remove the approach I was suggesting that messes with having to subscribe to things like the Just to address
I was approaching this from the point of view that the UI component would have to subscribe to something for the rendered UI to update whenever the flag changes. If the context changes will automatically update the value with the directive approach then this is no longer a concern and the directive approach feels easier to manage and thus a better developer experience 👍 |
Cool! How do we continue from here? |
Honestly I've been working on a lot of our internal OpenFeature stuff at work, so I don't have the time to take on something so big myself at the moment. I would support anyone who wants to work on this though. I have a decent amount of Angular experience I would be happy to lend in reviewing and testing. |
@juanparadox not sure if you want to do it? |
@lukas-reining please feel free to take a stab at it! |
Hi guys, At the moment i am exactly struggling on how create a new provider at the start of my lazy loading feature and could be that my "angular approach" to the usage of the js-sdk has some limitation. So in my scenario i have a service that wraps the methods of the "OpenFeature" class and i use it to store data in it (that sticks to the module that injects it) and customize the provider for each feature. I think that in generale wrapping external libs usage into custom services is recommended especially if you work with a big application. About possibility to use different domains how did you thought to manage the different clients in this Angular SDK? |
In general i think that the scenario in which the flag is returned as a boolean and not as an observable is quite cool. Not all the situation requires an automatic change of the feature flag value, sometime is something used "one shot" so both approaches could be useful. |
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> Adds an Angular SDK as discussed in #976. It mainly provides directives that conditionally render based on flag value and provider state. I did not inject any OpenFeature service or anything like that, as I think the directives will be the way to access feature flags in the templates, and the OpenFeature global API can be used directly in services. But I am not 100% sure on that one. Happy to receive feedback and opinions :) A small test app can be found here: https://github.com/open-feature/angular-test-app This can be used with [yalc](https://github.com/wclr/yalc). --------- Signed-off-by: Lukas Reining <lukas.reining@codecentric.de> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Requirements
We should implement an Angular SDK. The SDK would provide an "Angular-friendly" API and features, built on top of the Web SDK.
The list is not conclusive and is up for discussion, including the removal, update, or addition to this list:
OpenFeature
methods such assetProvider
andsetContext
and for a way to get the provider's statusI'm a little rusty with Angular since React is more my space, but I would like some opinions on how the subscription part of the developer experience should work. Reason being is because with my suggestions above, the user has to subscribe to a client inside of every consumer - is this the best way to allow the user to evaluate a value for a flag or can we do this a better way with Angular?
Another point to keep in mind is whether to build this using signals or observables?
Non-functional requirements:
The text was updated successfully, but these errors were encountered: