All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.harmony.kotlin.data.datasource.flow.FlowDataSource.kt Maven / Gradle / Ivy

package com.harmony.kotlin.data.datasource.flow

import com.harmony.kotlin.data.mapper.Mapper
import com.harmony.kotlin.data.query.Query
import com.harmony.kotlin.data.repository.flow.FlowGetRepository
import com.harmony.kotlin.data.repository.flow.FlowPutRepository
import com.harmony.kotlin.data.repository.flow.SingleFlowDeleteDataSourceRepository
import com.harmony.kotlin.data.repository.flow.SingleFlowGetDataSourceRepository
import com.harmony.kotlin.data.repository.flow.SingleFlowPutDataSourceRepository
import com.harmony.kotlin.data.repository.flow.withMapping
import kotlinx.coroutines.flow.Flow

// DataSources
interface FlowGetDataSource {
  fun get(query: Query): Flow

  @Deprecated("Use get instead")
  fun getAll(query: Query): Flow>
}

interface FlowPutDataSource {
  fun put(query: Query, value: V?): Flow

  @Deprecated("Use put instead")
  fun putAll(query: Query, value: List? = emptyList()): Flow>
}

interface FlowDeleteDataSource {
  fun delete(query: Query): Flow
}

//region Creation

// Extensions to create
fun  FlowGetDataSource.toFlowGetRepository() = SingleFlowGetDataSourceRepository(this)

fun  FlowGetDataSource.toFlowGetRepository(mapper: Mapper): FlowGetRepository = toFlowGetRepository().withMapping(mapper)

fun  FlowPutDataSource.toPutRepository() = SingleFlowPutDataSourceRepository(this)

fun  FlowPutDataSource.toPutRepository(toMapper: Mapper, fromMapper: Mapper): FlowPutRepository =
  toPutRepository().withMapping(toMapper, fromMapper)

fun FlowDeleteDataSource.toDeleteRepository() = SingleFlowDeleteDataSourceRepository(this)
//endregion




© 2015 - 2025 Weber Informatics LLC | Privacy Policy