Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use reified T in getOrCreateSimple
Browse files Browse the repository at this point in the history
arkivanov committed Jan 20, 2024
1 parent 323e234 commit 244547d
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions instance-keeper/api/android/instance-keeper.api
Original file line number Diff line number Diff line change
@@ -33,6 +33,10 @@ public final class com/arkivanov/essenty/instancekeeper/InstanceKeeperDispatcher
public static final fun InstanceKeeperDispatcher ()Lcom/arkivanov/essenty/instancekeeper/InstanceKeeperDispatcher;
}

public final class com/arkivanov/essenty/instancekeeper/InstanceKeeperExtKt {
public static final fun getOrCreateSimple (Lcom/arkivanov/essenty/instancekeeper/InstanceKeeper;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
}

public abstract interface class com/arkivanov/essenty/instancekeeper/InstanceKeeperOwner {
public abstract fun getInstanceKeeper ()Lcom/arkivanov/essenty/instancekeeper/InstanceKeeper;
}
4 changes: 4 additions & 0 deletions instance-keeper/api/jvm/instance-keeper.api
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ public final class com/arkivanov/essenty/instancekeeper/InstanceKeeperDispatcher
public static final fun InstanceKeeperDispatcher ()Lcom/arkivanov/essenty/instancekeeper/InstanceKeeperDispatcher;
}

public final class com/arkivanov/essenty/instancekeeper/InstanceKeeperExtKt {
public static final fun getOrCreateSimple (Lcom/arkivanov/essenty/instancekeeper/InstanceKeeper;Ljava/lang/Object;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
}

public abstract interface class com/arkivanov/essenty/instancekeeper/InstanceKeeperOwner {
public abstract fun getInstanceKeeper ()Lcom/arkivanov/essenty/instancekeeper/InstanceKeeper;
}
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ inline fun <reified T : InstanceKeeper.Instance> InstanceKeeper.getOrCreate(fact
*
* This overload is for simple cases when instance destroying is not required.
*/
inline fun <reified T> InstanceKeeper.getOrCreateSimple(key: Any, factory: () -> T): T =
inline fun <T> InstanceKeeper.getOrCreateSimple(key: Any, factory: () -> T): T =
getOrCreate(key = key) { SimpleInstance(factory()) }
.instance

0 comments on commit 244547d

Please sign in to comment.