Created
June 16, 2023 08:01
-
-
Save sphrak/1b1d1f1c0f7d9260a6f1434a77476218 to your computer and use it in GitHub Desktop.
dagger2 desktop jvm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@DeviceScope | |
@Component( | |
modules = [ | |
DeviceModule::class | |
], | |
dependencies = [ | |
// shared dependencies | |
AppComponent::class | |
] | |
) | |
interface DeviceComponent { | |
fun provideViewModel(): DeviceViewModel | |
@Component.Factory | |
interface Factory { | |
fun create( | |
appComponent: AppComponent | |
): DeviceComponent | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
object DeviceModule { | |
@Provides | |
fun provideCoroutineDispatcher(): CoroutineDispatcher = Dispatchers.IO | |
@Provides | |
fun provideCoroutineScope( | |
coroutineDispatcher: CoroutineDispatcher | |
): CoroutineScope = CoroutineScope(Job() + coroutineDispatcher) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Scope | |
@Retention | |
annotation class DeviceScope |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment