You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: set context during provider init on web (#919)
## This PR
- overloads the set provider methods to support defining context in the
web SDK
- updates the web sdk readme
## Related Issues
Fixes#748
## Notes
I decided to only support setting context in the web SDK because it is
less valuable on the server and the expected behavior was less clear due
to `domains`.
The behavior may need to be spec'd out. An issue in the spec repo has
been created.
open-feature/spec#219
---------
Signed-off-by: Michael Beemer <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
@@ -158,9 +158,16 @@ Sometimes, the value of a flag must consider some dynamic criteria about the app
158
158
In OpenFeature, we refer to this as [targeting](https://openfeature.dev/specification/glossary#targeting).
159
159
If the flag management system you're using supports targeting, you can provide the input data using the [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context).
160
160
161
+
```ts
162
+
// Sets global context during provider registration
Once context has been defined for a named client, it will override the global context for all clients using the associated provider.
259
+
Context can be cleared using for a named provider using `OpenFeature.clearContext("my-domain")` or call `OpenFeature.clearContexts()` to reset all context.
260
+
236
261
### Eventing
237
262
238
263
Events allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.
Context is merged by the SDK before a flag evaluation occurs.
165
+
The merge order is defined [here](https://openfeature.dev/specification/sections/evaluation-context#requirement-323) in the OpenFeature specification.
166
+
164
167
### Hooks
165
168
166
169
[Hooks](https://openfeature.dev/docs/reference/concepts/hooks) allow for custom logic to be added at well-defined points of the flag evaluation life-cycle.
0 commit comments