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
| ✅ |[Tracking](#tracking)| Associate user actions with feature flag evaluations. |
76
76
| ❌ |[Logging](#logging)| Integrate with popular logging packages. |
77
77
| ❌ |[Named clients](#named-clients)| Utilize multiple providers in a single application. |
78
-
|❌|[Eventing](#eventing)| React to state changes in the provider or flag management system. |
78
+
|✅|[Eventing](#eventing)| React to state changes in the provider or flag management system. |
79
79
| ✅ |[Shutdown](#shutdown)| Gracefully clean up a provider during application shutdown. |
80
80
| ⚠️ |[Extending](#extending)| Extend OpenFeature with custom providers and hooks. |
81
81
@@ -171,13 +171,37 @@ Tracking is optionally implemented by Providers.
171
171
172
172
Logging customization is not yet available in the Kotlin SDK.
173
173
174
+
It is possible to write and inject logging `Hook`s to log events at different stages of the flag evaluation life-cycle.
175
+
174
176
### Named clients
175
177
176
178
Support for named clients is not yet available in the Kotlin SDK.
177
179
178
180
### Eventing
179
181
180
-
Support for eventing is not yet available in the Kotlin SDK.
182
+
Events from the Provider allow the SDK to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.
183
+
Events are optional which mean that not all Providers will emit them and it is not a must have. Some providers support additional events, such as `PROVIDER_CONFIGURATION_CHANGED`.
184
+
185
+
Please refer to the documentation of the provider you're using to see what events are supported.
186
+
187
+
Example usage:
188
+
```kotlin
189
+
viewModelScope.launch {
190
+
OpenFeatureAPI.observe().collect {
191
+
println(">> Provider event received")
192
+
}
193
+
}
194
+
195
+
viewModelScope.launch {
196
+
OpenFeatureAPI.setProviderAndWait(
197
+
MyFeatureProvider(),
198
+
Dispatchers.IO,
199
+
myEvaluationContext
200
+
)
201
+
}
202
+
```
203
+
204
+
<!-- (It's only possible to observe events from the global `OpenFeatureAPI`, until multiple providers are supported) -->
181
205
182
206
### Shutdown
183
207
@@ -244,6 +268,18 @@ class NewProvider(override val hooks: List<Hook<*>>, override val metadata: Meta
Copy file name to clipboardExpand all lines: android/api/android.api
+40-5Lines changed: 40 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -63,12 +63,14 @@ public abstract interface class dev/openfeature/sdk/FeatureProvider {
63
63
public abstract fun getObjectEvaluation (Ljava/lang/String;Ldev/openfeature/sdk/Value;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
64
64
public abstract fun getStringEvaluation (Ljava/lang/String;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
65
65
public abstract fun initialize (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
66
+
public abstract fun observe ()Lkotlinx/coroutines/flow/Flow;
66
67
public abstract fun onContextSet (Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
67
68
public abstract fun shutdown ()V
68
69
public abstract fun track (Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
69
70
}
70
71
71
72
public final class dev/openfeature/sdk/FeatureProvider$DefaultImpls {
73
+
public static fun observe (Ldev/openfeature/sdk/FeatureProvider;)Lkotlinx/coroutines/flow/Flow;
72
74
public static fun track (Ldev/openfeature/sdk/FeatureProvider;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
73
75
}
74
76
@@ -237,6 +239,7 @@ public class dev/openfeature/sdk/NoOpProvider : dev/openfeature/sdk/FeatureProvi
237
239
public fun getObjectEvaluation (Ljava/lang/String;Ldev/openfeature/sdk/Value;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
238
240
public fun getStringEvaluation (Ljava/lang/String;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
239
241
public fun initialize (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
242
+
public fun observe ()Lkotlinx/coroutines/flow/Flow;
240
243
public fun onContextSet (Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
241
244
public fun shutdown ()V
242
245
public fun track (Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
@@ -257,23 +260,24 @@ public final class dev/openfeature/sdk/OpenFeatureAPI {
257
260
public static final field INSTANCE Ldev/openfeature/sdk/OpenFeatureAPI;
258
261
public final fun addHooks (Ljava/util/List;)V
259
262
public final fun clearHooks ()V
260
-
public final fun clearProvider ()V
263
+
public final fun clearProvider (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
261
264
public final fun getClient (Ljava/lang/String;Ljava/lang/String;)Ldev/openfeature/sdk/Client;
262
265
public static synthetic fun getClient$default (Ldev/openfeature/sdk/OpenFeatureAPI;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/openfeature/sdk/Client;
263
266
public final fun getEvaluationContext ()Ldev/openfeature/sdk/EvaluationContext;
264
267
public final fun getHooks ()Ljava/util/List;
265
268
public final fun getProvider ()Ldev/openfeature/sdk/FeatureProvider;
266
269
public final fun getProviderMetadata ()Ldev/openfeature/sdk/ProviderMetadata;
270
+
public final fun getProvidersFlow ()Lkotlinx/coroutines/flow/MutableStateFlow;
267
271
public final fun getStatus ()Ldev/openfeature/sdk/OpenFeatureStatus;
268
272
public final fun getStatusFlow ()Lkotlinx/coroutines/flow/Flow;
269
273
public final fun setEvaluationContext (Ldev/openfeature/sdk/EvaluationContext;Lkotlinx/coroutines/CoroutineDispatcher;)V
270
274
public static synthetic fun setEvaluationContext$default (Ldev/openfeature/sdk/OpenFeatureAPI;Ldev/openfeature/sdk/EvaluationContext;Lkotlinx/coroutines/CoroutineDispatcher;ILjava/lang/Object;)V
271
275
public final fun setEvaluationContextAndWait (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
272
276
public final fun setProvider (Ldev/openfeature/sdk/FeatureProvider;Lkotlinx/coroutines/CoroutineDispatcher;Ldev/openfeature/sdk/EvaluationContext;)V
273
277
public static synthetic fun setProvider$default (Ldev/openfeature/sdk/OpenFeatureAPI;Ldev/openfeature/sdk/FeatureProvider;Lkotlinx/coroutines/CoroutineDispatcher;Ldev/openfeature/sdk/EvaluationContext;ILjava/lang/Object;)V
274
-
public final fun setProviderAndWait (Ldev/openfeature/sdk/FeatureProvider;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
275
-
public static synthetic fun setProviderAndWait$default (Ldev/openfeature/sdk/OpenFeatureAPI;Ldev/openfeature/sdk/FeatureProvider;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
276
-
public final fun shutdown ()V
278
+
public final fun setProviderAndWait (Ldev/openfeature/sdk/FeatureProvider;Ldev/openfeature/sdk/EvaluationContext;Lkotlinx/coroutines/CoroutineDispatcher;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
279
+
public static synthetic fun setProviderAndWait$default (Ldev/openfeature/sdk/OpenFeatureAPI;Ldev/openfeature/sdk/FeatureProvider;Ldev/openfeature/sdk/EvaluationContext;Lkotlinx/coroutines/CoroutineDispatcher;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
280
+
public final fun shutdown (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
277
281
}
278
282
279
283
public final class dev/openfeature/sdk/OpenFeatureClient : dev/openfeature/sdk/Client {
@@ -325,7 +329,8 @@ public final class dev/openfeature/sdk/OpenFeatureStatus$Error : dev/openfeature
325
329
}
326
330
327
331
public final class dev/openfeature/sdk/OpenFeatureStatus$Fatal : dev/openfeature/sdk/OpenFeatureStatus {
328
-
public static final field INSTANCE Ldev/openfeature/sdk/OpenFeatureStatus$Fatal;
332
+
public fun <init> (Ldev/openfeature/sdk/exceptions/OpenFeatureError;)V
333
+
public final fun getError ()Ldev/openfeature/sdk/exceptions/OpenFeatureError;
329
334
}
330
335
331
336
public final class dev/openfeature/sdk/OpenFeatureStatus$NotReady : dev/openfeature/sdk/OpenFeatureStatus {
@@ -589,6 +594,36 @@ public final class dev/openfeature/sdk/Value$Structure : dev/openfeature/sdk/Val
589
594
public fun toString ()Ljava/lang/String;
590
595
}
591
596
597
+
public abstract interface class dev/openfeature/sdk/events/OpenFeatureProviderEvents {
598
+
}
599
+
600
+
public final class dev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderConfigurationChanged : dev/openfeature/sdk/events/OpenFeatureProviderEvents {
601
+
public static final field INSTANCE Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderConfigurationChanged;
602
+
}
603
+
604
+
public final class dev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderError : dev/openfeature/sdk/events/OpenFeatureProviderEvents {
605
+
public fun <init> (Ldev/openfeature/sdk/exceptions/OpenFeatureError;)V
606
+
public final fun component1 ()Ldev/openfeature/sdk/exceptions/OpenFeatureError;
607
+
public final fun copy (Ldev/openfeature/sdk/exceptions/OpenFeatureError;)Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderError;
608
+
public static synthetic fun copy$default (Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderError;Ldev/openfeature/sdk/exceptions/OpenFeatureError;ILjava/lang/Object;)Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderError;
609
+
public fun equals (Ljava/lang/Object;)Z
610
+
public final fun getError ()Ldev/openfeature/sdk/exceptions/OpenFeatureError;
611
+
public fun hashCode ()I
612
+
public fun toString ()Ljava/lang/String;
613
+
}
614
+
615
+
public final class dev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderNotReady : dev/openfeature/sdk/events/OpenFeatureProviderEvents {
616
+
public static final field INSTANCE Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderNotReady;
617
+
}
618
+
619
+
public final class dev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderReady : dev/openfeature/sdk/events/OpenFeatureProviderEvents {
620
+
public static final field INSTANCE Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderReady;
621
+
}
622
+
623
+
public final class dev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderStale : dev/openfeature/sdk/events/OpenFeatureProviderEvents {
624
+
public static final field INSTANCE Ldev/openfeature/sdk/events/OpenFeatureProviderEvents$ProviderStale;
625
+
}
626
+
592
627
public final class dev/openfeature/sdk/exceptions/ErrorCode : java/lang/Enum {
593
628
public static final field FLAG_NOT_FOUND Ldev/openfeature/sdk/exceptions/ErrorCode;
594
629
public static final field GENERAL Ldev/openfeature/sdk/exceptions/ErrorCode;
0 commit comments