add factory for MapCRUDRepo

This commit is contained in:
InsanusMokrassar 2020-10-14 21:31:26 +06:00
parent e22595339e
commit 3c393fdd21

View File

@ -89,3 +89,8 @@ fun <ObjectType, IdType, InputValueType> MapCRUDRepo(
override suspend fun createObject(newValue: InputValueType): Pair<IdType, ObjectType> = createCallback(newValue)
}
fun <ObjectType, IdType, InputValueType> MutableMap<IdType, ObjectType>.asCrudRepo(
updateCallback: suspend (newValue: InputValueType, id: IdType, old: ObjectType) -> ObjectType,
createCallback: suspend (newValue: InputValueType) -> Pair<IdType, ObjectType>
) = MapCRUDRepo(this, updateCallback, createCallback)