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

commonMain.com.paoapps.fifi.auth.model.AuthModelUtils.kt Maven / Gradle / Ivy

package com.paoapps.fifi.auth.model

import com.paoapps.blockedcache.BlockedCache
import com.paoapps.blockedcache.BlockedCacheData
import com.paoapps.fifi.api.ClientApi
import com.paoapps.fifi.auth.IdentifiableClaims
import com.paoapps.fifi.auth.api.AuthClientApi
import com.paoapps.fifi.model.ModelEnvironment
import com.paoapps.fifi.model.ModelHelper
import com.paoapps.fifi.model.datacontainer.DataContainer
import com.paoapps.fifi.model.createBlockCache
import kotlinx.coroutines.flow.flowOf
import kotlin.time.Duration

fun , Environment : ModelEnvironment, UserId, Api: AuthClientApi> createBlockCache(
    authModel: AuthModel,
    dataContainer: DataContainer,
    duration: Duration,
    expire: Duration?,
    selector: (ModelData) -> BlockedCacheData?,
    name: String,
    triggerOnUserIdChange: Boolean = true,
    isDebugEnabled: Boolean = false
): BlockedCache {

    val userIdChangedFlow = if (triggerOnUserIdChange) authModel.userIdFlow else flowOf(Unit)

    return createBlockCache(dataContainer, duration, expire, selector, name, userIdChangedFlow, isDebugEnabled)
}

fun , Environment : ModelEnvironment, UserId, Api: AuthClientApi> ModelHelper, Api>.createBlockCache(
    authModel: AuthModel,
    duration: Duration,
    expire: Duration?,
    triggerOnUserIdChange: Boolean = true,
    isDebugEnabled: Boolean = false
): BlockedCache {
    return createBlockCache(
        authModel = authModel,
        dataContainer = modelDataContainer,
        duration = duration,
        expire = expire,
        selector = { it },
        name = name,
        triggerOnUserIdChange = triggerOnUserIdChange,
        isDebugEnabled = isDebugEnabled
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy