mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
976 B
Kotlin
33 lines
976 B
Kotlin
package org.tasks.injection
|
|
|
|
import dagger.Module
|
|
import dagger.Provides
|
|
import dagger.hilt.InstallIn
|
|
import dagger.hilt.android.components.ActivityRetainedComponent
|
|
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
|
import kotlinx.coroutines.channels.BufferOverflow
|
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
import org.tasks.ui.MainActivityEventBus
|
|
import org.tasks.ui.TaskEditEventBus
|
|
import org.tasks.ui.TaskListEventBus
|
|
|
|
@Module
|
|
@InstallIn(ActivityRetainedComponent::class)
|
|
class ActivityRetainedModule {
|
|
@Provides
|
|
@ActivityRetainedScoped
|
|
fun getTaskListBus(): TaskListEventBus = makeFlow()
|
|
|
|
@Provides
|
|
@ActivityRetainedScoped
|
|
fun getMainActivityBus(): MainActivityEventBus = makeFlow()
|
|
|
|
@Provides
|
|
@ActivityRetainedScoped
|
|
fun getTaskEditBus(): TaskEditEventBus = makeFlow()
|
|
|
|
private fun <T> makeFlow() = MutableSharedFlow<T>(
|
|
extraBufferCapacity = 1,
|
|
onBufferOverflow = BufferOverflow.DROP_OLDEST
|
|
)
|
|
} |