Skip to content

Commit 9f73375

Browse files
committed
chore: update api spec
Signed-off-by: Nicklas Lundin <[email protected]>
1 parent 69cbc01 commit 9f73375

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

android/api/android.api

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ public abstract interface class dev/openfeature/sdk/FeatureProvider {
6363
public abstract fun getObjectEvaluation (Ljava/lang/String;Ldev/openfeature/sdk/Value;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
6464
public abstract fun getStringEvaluation (Ljava/lang/String;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
6565
public abstract fun initialize (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
66+
public abstract fun observe ()Lkotlinx/coroutines/flow/Flow;
6667
public abstract fun onContextSet (Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
6768
public abstract fun shutdown ()V
6869
public abstract fun track (Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
6970
}
7071

7172
public final class dev/openfeature/sdk/FeatureProvider$DefaultImpls {
73+
public static fun observe (Ldev/openfeature/sdk/FeatureProvider;)Lkotlinx/coroutines/flow/Flow;
7274
public static fun track (Ldev/openfeature/sdk/FeatureProvider;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
7375
}
7476

@@ -237,6 +239,7 @@ public class dev/openfeature/sdk/NoOpProvider : dev/openfeature/sdk/FeatureProvi
237239
public fun getObjectEvaluation (Ljava/lang/String;Ldev/openfeature/sdk/Value;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
238240
public fun getStringEvaluation (Ljava/lang/String;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
239241
public fun initialize (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
242+
public fun observe ()Lkotlinx/coroutines/flow/Flow;
240243
public fun onContextSet (Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
241244
public fun shutdown ()V
242245
public fun track (Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
@@ -264,15 +267,16 @@ public final class dev/openfeature/sdk/OpenFeatureAPI {
264267
public final fun getHooks ()Ljava/util/List;
265268
public final fun getProvider ()Ldev/openfeature/sdk/FeatureProvider;
266269
public final fun getProviderMetadata ()Ldev/openfeature/sdk/ProviderMetadata;
270+
public final fun getProvidersFlow ()Lkotlinx/coroutines/flow/Flow;
267271
public final fun getStatus ()Ldev/openfeature/sdk/OpenFeatureStatus;
268272
public final fun getStatusFlow ()Lkotlinx/coroutines/flow/Flow;
269273
public final fun setEvaluationContext (Ldev/openfeature/sdk/EvaluationContext;Lkotlinx/coroutines/CoroutineDispatcher;)V
270274
public static synthetic fun setEvaluationContext$default (Ldev/openfeature/sdk/OpenFeatureAPI;Ldev/openfeature/sdk/EvaluationContext;Lkotlinx/coroutines/CoroutineDispatcher;ILjava/lang/Object;)V
271275
public final fun setEvaluationContextAndWait (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
272276
public final fun setProvider (Ldev/openfeature/sdk/FeatureProvider;Lkotlinx/coroutines/CoroutineDispatcher;Ldev/openfeature/sdk/EvaluationContext;)V
273277
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;
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;
276280
public final fun shutdown ()V
277281
}
278282

@@ -325,7 +329,8 @@ public final class dev/openfeature/sdk/OpenFeatureStatus$Error : dev/openfeature
325329
}
326330

327331
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;
329334
}
330335

331336
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
589594
public fun toString ()Ljava/lang/String;
590595
}
591596

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+
592627
public final class dev/openfeature/sdk/exceptions/ErrorCode : java/lang/Enum {
593628
public static final field FLAG_NOT_FOUND Ldev/openfeature/sdk/exceptions/ErrorCode;
594629
public static final field GENERAL Ldev/openfeature/sdk/exceptions/ErrorCode;

android/src/main/java/dev/openfeature/sdk/OpenFeatureAPI.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ object OpenFeatureAPI {
3030
private val NOOP_PROVIDER = NoOpProvider()
3131
private var provider: FeatureProvider = NOOP_PROVIDER
3232
private var context: EvaluationContext? = null
33-
val providersFlow: MutableStateFlow<FeatureProvider> = MutableStateFlow(NOOP_PROVIDER)
33+
private val _providersFlow: MutableStateFlow<FeatureProvider> = MutableStateFlow(NOOP_PROVIDER)
34+
val providersFlow: Flow<FeatureProvider> get() = _providersFlow
3435

3536
private val _statusFlow: MutableSharedFlow<OpenFeatureStatus> =
3637
MutableSharedFlow<OpenFeatureStatus>(replay = 1, extraBufferCapacity = 5)
@@ -103,7 +104,7 @@ object OpenFeatureAPI {
103104
this@OpenFeatureAPI.provider = provider.also {
104105
_statusFlow.emit(OpenFeatureStatus.NotReady)
105106
}
106-
providersFlow.value = provider
107+
_providersFlow.value = provider
107108
if (initialContext != null) context = initialContext
108109
try {
109110
listenToProviderEvents(provider, dispatcher)
@@ -135,7 +136,7 @@ object OpenFeatureAPI {
135136
fun clearProvider() {
136137
getProvider().shutdown()
137138
provider = NOOP_PROVIDER
138-
providersFlow.value = NOOP_PROVIDER
139+
_providersFlow.value = NOOP_PROVIDER
139140
_statusFlow.tryEmit(OpenFeatureStatus.NotReady)
140141
}
141142

@@ -258,7 +259,6 @@ object OpenFeatureAPI {
258259
/**
259260
* Observe events from currently configured Provider.
260261
*/
261-
// reified T : OpenFeatureProviderEvents
262262
@OptIn(ExperimentalCoroutinesApi::class)
263263
inline fun <reified T : OpenFeatureProviderEvents> observe(): Flow<T> = providersFlow
264264
.flatMapLatest { it.observe() }.filterIsInstance()

0 commit comments

Comments
 (0)