Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DI: Replace Dispatchers.IO with injected CoroutineDispatcher #506

Merged

Conversation

ksharma-xyz
Copy link
Owner

@ksharma-xyz ksharma-xyz commented Jan 3, 2025

TL;DR

Replaced hardcoded Dispatchers.IO with injected CoroutineDispatcher across ViewModels and network services.

What changed?

  • Added CoroutineDispatcher as a constructor parameter to ViewModels and services
  • Updated Koin DI modules to inject IODispatcher
  • Removed direct Dispatchers.IO usage in favor of injected dispatcher
  • Updated SplashViewModel, SavedTripsViewModel, ThemeSelectionViewModel, TimeTableViewModel, and RealTripPlanningService

Why make this change?

  • Improves testability by allowing dispatcher injection
  • Makes coroutine context usage more consistent across the codebase
  • Follows dependency injection best practices
  • Makes it easier to swap dispatchers for testing purposes

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@ksharma-xyz ksharma-xyz changed the title Inject dispatcher from outside rather than hardcode DI: Replace Dispatchers.IO with injected CoroutineDispatcher Jan 3, 2025
Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ksharma-xyz ksharma-xyz marked this pull request as ready for review January 3, 2025 13:46
@ksharma-xyz ksharma-xyz merged commit 6d44d67 into main Jan 3, 2025
4 checks passed
@ksharma-xyz ksharma-xyz deleted the 01-03-inject_dispatcher_from_outside_rather_than_hardcode branch January 3, 2025 13:55
@ksharma-xyz ksharma-xyz added this to the 1.0.5 milestone Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant