commonMain.io.github.jan.supabase.plugins.PluginManager.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of supabase-kt Show documentation
Show all versions of supabase-kt Show documentation
A Kotlin Multiplatform Supabase SDK
package io.github.jan.supabase.plugins
import io.github.jan.supabase.SupabaseClientBuilder
/**
* The plugin manager is used to manage installed plugins
* @param installedPlugins A map of installed plugins. You can install plugins by using the [SupabaseClientBuilder.install] method
*/
class PluginManager(val installedPlugins: Map>) {
/**
* Retrieve an installed plugin using it's [Provider] or null if no such plugin is installed
*/
inline fun , Config, Provider : SupabasePluginProvider> getPluginOrNull(provider: Provider): Plugin? {
return installedPlugins[provider.key] as? Plugin
}
/**
* Retrieve an installed plugin using it's [Provider]
*/
inline fun , Config, Provider : SupabasePluginProvider> getPlugin(provider: Provider): Plugin {
return getPluginOrNull(provider) ?: error("Plugin ${provider.key} not installed or not of type ${Plugin::class.simpleName}. Consider installing ${Plugin::class.simpleName} within your SupabaseClientBuilder")
}
/**
* Closes all installed plugins
*/
suspend inline fun closeAllPlugins() {
installedPlugins.values.forEach { it.close() }
}
}