@@ -55,12 +55,12 @@ dependencies {
5555### Usage
5656
5757``` kotlin
58- // configure a provider and get client
5958coroutineScope.launch(Dispatchers .IO ) {
59+ // configure a provider, wait for it to complete its initialization tasks
6060 OpenFeatureAPI .setProviderAndWait(customProvider)
6161 val client = OpenFeatureAPI .getClient()
6262
63- // get a bool flag value
63+ // get a bool flag value
6464 client.getBooleanValue(" boolFlag" , default = false )
6565}
6666```
@@ -74,7 +74,7 @@ coroutineScope.launch(Dispatchers.IO) {
7474| ✅ | [ Hooks] ( #hooks ) | Add functionality to various stages of the flag evaluation life-cycle. |
7575| ❌ | Logging | Integrate with popular logging packages. |
7676| ❌ | Named clients | Utilize multiple providers in a single application. |
77- | ⚠ ️ | [ Eventing] ( #eventing ) | React to state changes in the provider or flag management system. |
77+ | ✅ ️ | [ Eventing] ( #eventing ) | React to state changes in the provider or flag management system. |
7878| ✅ | [ Shutdown] ( #shutdown ) | Gracefully clean up a provider during application shutdown. |
7979| ⚠️ | [ Extending] ( #extending ) | Extend OpenFeature with custom providers and hooks. |
8080
@@ -89,9 +89,11 @@ If the provider you're looking for hasn't been created yet, see the [develop a p
8989Once you've added a provider as a dependency, it can be registered with OpenFeature like this:
9090
9191``` kotlin
92- OpenFeatureAPI .setProvider (MyProvider ())
92+ OpenFeatureAPI .setProviderAndWait (MyProvider ())
9393```
9494
95+ _ (Asynchronous API that doesn't wait is also available)_
96+
9597
9698### Targeting
9799
@@ -137,13 +139,28 @@ Some providers support additional events, such as `PROVIDER_CONFIGURATION_CHANGE
137139
138140Please refer to the documentation of the provider you're using to see what events are supported.
139141
142+ Example usage:
140143``` kotlin
141- OpenFeatureAPI .observeEvents<OpenFeatureEvents .ProviderReady >()
142- ?.collect {
143- // do something once the provider is ready
144- }
144+ viewModelScope.launch {
145+ OpenFeatureAPI .observe<OpenFeatureEvents .ProviderReady >().collect {
146+ println (" >> ProviderReady event received" )
147+ }
148+ }
149+
150+ viewModelScope.launch {
151+ OpenFeatureAPI .setProviderAndWait(
152+ ConfidenceFeatureProvider .create(
153+ applicationContext,
154+ clientSecret
155+ ),
156+ Dispatchers .IO ,
157+ myEvaluationContext
158+ )
159+ }
145160```
146161
162+ <!-- (It's only possible to observe events from the global `OpenFeatureAPI`, until multiple providers are supported) -->
163+
147164### Shutdown
148165
149166The OpenFeature API provides a close function to perform a cleanup of the registered provider.
@@ -210,6 +227,13 @@ class NewProvider(override val hooks: List<Hook<*>>, override val metadata: Meta
210227 // add necessary changes on context change
211228 }
212229
230+ override fun observe (): Flow <OpenFeatureEvents > {
231+ // return a `Flow` of the Events
232+ }
233+
234+ override fun getProviderStatus (): OpenFeatureEvents {
235+ // return the event representative of the current Provider Status
236+ }
213237}
214238```
215239
0 commit comments