androidMain.com.algolia.instantsearch.insights.internal.InsightsController.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of instantsearch-insights Show documentation
Show all versions of instantsearch-insights Show documentation
InstantSearch Android is a library providing widgets and helpers to help you build the best instant-search experience on Android with Algolia. It is built on top of Algolia's Kotlin API Client to provide you a high-level solution to quickly build various search interfaces.
package com.algolia.instantsearch.insights.internal
import androidx.work.WorkManager
import com.algolia.instantsearch.insights.Insights
import com.algolia.instantsearch.insights.internal.cache.InsightsEventCache
import com.algolia.instantsearch.insights.internal.data.distant.InsightsDistantRepository
import com.algolia.instantsearch.insights.internal.data.local.InsightsLocalRepository
import com.algolia.instantsearch.insights.internal.data.settings.InsightsSettings
import com.algolia.instantsearch.insights.internal.logging.InsightsLogger
import com.algolia.instantsearch.insights.internal.uploader.InsightsEventUploader
import com.algolia.instantsearch.insights.internal.worker.InsightsWorkManager
import com.algolia.instantsearch.insights.sharedInsights
import com.algolia.search.model.IndexName
internal fun registerInsightsController(
indexName: IndexName,
localRepository: InsightsLocalRepository,
distantRepository: InsightsDistantRepository,
workManager: WorkManager,
settings: InsightsSettings,
configuration: Insights.Configuration = Insights.Configuration(),
): Insights {
val saver = InsightsEventCache(localRepository)
val uploader = InsightsEventUploader(localRepository, distantRepository)
val worker = InsightsWorkManager(workManager, settings)
return InsightsController(indexName, worker, saver, uploader, configuration.generateTimestamps).also {
it.userToken = configuration.defaultUserToken
sharedInsights = it
InsightsMap[indexName] = it
InsightsLogger.log("Registering new Insights for indexName $indexName. Previous instance: $it")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy