From 3c393fdd216613c860490afea495f74adb594e9b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 14 Oct 2020 21:31:26 +0600 Subject: [PATCH] add factory for MapCRUDRepo --- .../kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt index 96bbbfa18b2..a2194f0b96a 100644 --- a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt +++ b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapCRUDRepo.kt @@ -89,3 +89,8 @@ fun MapCRUDRepo( override suspend fun createObject(newValue: InputValueType): Pair = createCallback(newValue) } + +fun MutableMap.asCrudRepo( + updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType, + createCallback: suspend (newValue: InputValueType) -> Pair +) = MapCRUDRepo(this, updateCallback, createCallback)