diff --git a/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/ExperimentalInstanceKeeperApi.kt b/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/ExperimentalInstanceKeeperApi.kt new file mode 100644 index 0000000..f8728f3 --- /dev/null +++ b/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/ExperimentalInstanceKeeperApi.kt @@ -0,0 +1,9 @@ +package com.arkivanov.essenty.instancekeeper + +/** + * Marks experimental API in Essenty. An experimental API can be changed or removed at any time. + */ +@RequiresOptIn(level = RequiresOptIn.Level.WARNING) +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +annotation class ExperimentalInstanceKeeperApi diff --git a/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt b/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt index b08eab9..c22d520 100644 --- a/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt +++ b/instance-keeper/src/commonMain/kotlin/com/arkivanov/essenty/instancekeeper/InstanceKeeperExt.kt @@ -1,7 +1,6 @@ package com.arkivanov.essenty.instancekeeper import com.arkivanov.essenty.instancekeeper.InstanceKeeper.SimpleInstance -import com.arkivanov.essenty.utils.internal.ExperimentalEssentyApi import kotlin.reflect.typeOf /** @@ -29,14 +28,14 @@ inline fun InstanceKeeper.getOrCreate(fact /** * A convenience function for [InstanceKeeper.getOrCreate]. */ -@ExperimentalEssentyApi +@ExperimentalInstanceKeeperApi inline fun InstanceKeeperOwner.retainedInstance(key: Any, factory: () -> T): T = instanceKeeper.getOrCreate(key = key, factory = factory) /** * A convenience function for [InstanceKeeper.getOrCreate]. */ -@ExperimentalEssentyApi +@ExperimentalInstanceKeeperApi inline fun InstanceKeeperOwner.retainedInstance(factory: () -> T): T = instanceKeeper.getOrCreate(factory = factory) @@ -62,13 +61,13 @@ inline fun InstanceKeeper.getOrCreateSimple(factory: () -> T): T = /** * A convenience function for [InstanceKeeper.getOrCreateSimple]. */ -@ExperimentalEssentyApi +@ExperimentalInstanceKeeperApi inline fun InstanceKeeperOwner.retainedSimpleInstance(key: Any, factory: () -> T): T = instanceKeeper.getOrCreateSimple(key = key, factory = factory) /** * A convenience function for [InstanceKeeper.getOrCreateSimple]. */ -@ExperimentalEssentyApi +@ExperimentalInstanceKeeperApi inline fun InstanceKeeperOwner.retainedSimpleInstance(factory: () -> T): T = instanceKeeper.getOrCreateSimple(factory = factory) diff --git a/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/ExperimentalStateKeeperApi.kt b/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/ExperimentalStateKeeperApi.kt new file mode 100644 index 0000000..1f466b3 --- /dev/null +++ b/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/ExperimentalStateKeeperApi.kt @@ -0,0 +1,9 @@ +package com.arkivanov.essenty.statekeeper + +/** + * Marks experimental API in Essenty. An experimental API can be changed or removed at any time. + */ +@RequiresOptIn(level = RequiresOptIn.Level.WARNING) +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +annotation class ExperimentalStateKeeperApi diff --git a/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt b/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt index ce9d3fa..9a7cb2c 100644 --- a/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt +++ b/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializer.kt @@ -1,6 +1,5 @@ package com.arkivanov.essenty.statekeeper -import com.arkivanov.essenty.utils.internal.ExperimentalEssentyApi import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.KSerializer import kotlinx.serialization.descriptors.SerialDescriptor @@ -18,7 +17,7 @@ import kotlin.reflect.KClass /** * Creates a polymorphic [KSerializer] for the specified class of type [T] using the specified [module]. */ -@ExperimentalEssentyApi +@ExperimentalStateKeeperApi @ExperimentalSerializationApi inline fun polymorphicSerializer(module: SerializersModule): KSerializer = polymorphicSerializer(baseClass = T::class, module = module) @@ -26,7 +25,7 @@ inline fun polymorphicSerializer(module: SerializersModule): K /** * Creates a polymorphic [KSerializer] for the specified [baseClass] class using the specified [module]. */ -@ExperimentalEssentyApi +@ExperimentalStateKeeperApi @ExperimentalSerializationApi fun polymorphicSerializer(baseClass: KClass, module: SerializersModule): KSerializer = PolymorphicSerializer(baseClass = baseClass, module = module) diff --git a/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt b/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt index 9dc8aac..c48daa9 100644 --- a/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt +++ b/state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExt.kt @@ -1,6 +1,5 @@ package com.arkivanov.essenty.statekeeper -import com.arkivanov.essenty.utils.internal.ExperimentalEssentyApi import kotlinx.serialization.KSerializer import kotlin.properties.PropertyDelegateProvider import kotlin.properties.ReadOnlyProperty @@ -21,7 +20,7 @@ import kotlin.reflect.KProperty * returns an object of type [T]. * @return [PropertyDelegateProvider] of type [T], typically used to define a delegated property. */ -@ExperimentalEssentyApi +@ExperimentalStateKeeperApi inline fun StateKeeper.saveable( serializer: KSerializer, crossinline state: (T) -> S, @@ -49,7 +48,7 @@ inline fun StateKeeper.saveable( * returns an object of type [T]. * @return [PropertyDelegateProvider] of type [T], typically used to define a delegated property. */ -@ExperimentalEssentyApi +@ExperimentalStateKeeperApi inline fun StateKeeperOwner.saveable( serializer: KSerializer, crossinline state: (T) -> S, @@ -74,7 +73,7 @@ inline fun StateKeeperOwner.saveable( * @param init a function returning the initial value of type [T]. * @return [PropertyDelegateProvider] of type [T], typically used to define a delegated property. */ -@ExperimentalEssentyApi +@ExperimentalStateKeeperApi inline fun StateKeeper.saveable( serializer: KSerializer, key: String? = null, @@ -106,7 +105,7 @@ inline fun StateKeeper.saveable( * @param init a function returning the initial value of type [T]. * @return [PropertyDelegateProvider] of type [T], typically used to define a delegated property. */ -@ExperimentalEssentyApi +@ExperimentalStateKeeperApi inline fun StateKeeperOwner.saveable( serializer: KSerializer, key: String? = null, diff --git a/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt b/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt index 3e7dfd1..c71865f 100644 --- a/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt +++ b/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/PolymorphicSerializerTest.kt @@ -1,6 +1,5 @@ package com.arkivanov.essenty.statekeeper -import com.arkivanov.essenty.utils.internal.ExperimentalEssentyApi import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable @@ -30,7 +29,7 @@ class PolymorphicSerializerTest { @Serializable private data class Some2(val data: SerializableData) : Some - @OptIn(ExperimentalEssentyApi::class, ExperimentalSerializationApi::class) + @OptIn(ExperimentalStateKeeperApi::class, ExperimentalSerializationApi::class) private object SomeSerializer : KSerializer by polymorphicSerializer( SerializersModule { polymorphic(Some::class) { diff --git a/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt b/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt index e77c84a..429df48 100644 --- a/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt +++ b/state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/StateKeeperExtTest.kt @@ -1,11 +1,10 @@ package com.arkivanov.essenty.statekeeper -import com.arkivanov.essenty.utils.internal.ExperimentalEssentyApi import kotlinx.serialization.builtins.serializer import kotlin.test.Test import kotlin.test.assertEquals -@OptIn(ExperimentalEssentyApi::class) +@OptIn(ExperimentalStateKeeperApi::class) class StateKeeperExtTest { @Test