refactor: improve PlaybackModule lifecycle management with onClose
This commit is contained in:
1 parent
4f23e0eb54
commit
2957227f69
2 files changed
+5
-3
No files matched your search
@@ -6,7 +6,10 @@ import org.koin.core.module.Module
|
||||
import org.koin.core.module.dsl.bind
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.dsl.module
|
||||
import org.koin.dsl.onClose
|
||||
|
||||
val playbackModule: Module = module {
|
||||
singleOf(::PlaybackRepositoryImpl) { bind<PlaybackRepository>() }
|
||||
// Release the audio player when the app is destroyed: closing the composition-scoped Koin drops
|
||||
// this single and fires onClose (only if it was ever created).
|
||||
singleOf(::PlaybackRepositoryImpl) { bind<PlaybackRepository>() } onClose { it?.release() }
|
||||
}
|
||||
Reference in new issue
Block a user