Migrate from ViewModels to Decompose architecture#34
Open
AlexGladkov wants to merge 4 commits into
Open
Conversation
Defines the full plan to replace all ViewModels and Jetpack Compose Navigation with Decompose Components, nested Child Stacks, Kodein DIAware pattern, and Essenty lifecycle-coroutines. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit migrates the entire JetHabit application from Jetpack Compose Navigation + androidx.lifecycle.ViewModel to Arkadii Ivanov's Decompose library. Changes: - Add Decompose (3.2.0-alpha05) and Essenty (2.2.0-alpha02) dependencies - Remove compose-navigation and compose-viewmodel dependencies - Create RootComponent with Child Stack managing Splash/Main/Create flows - Create MainComponent managing bottom navigation with 5 tab stacks - Replace all ViewModels with Decompose Components: * DailyListComponent, DetailComponent * HealthListComponent, TrackHabitComponent, CreateHabitComponent * StatisticsComponent, ChatComponent * ProfileStartComponent, EditProfileComponent, SettingsComponent, ProjectListComponent - Update all Screen composables to use Components instead of ViewModels - Replace MutableStateFlow with MutableValue from Decompose - Replace viewModelScope with coroutineScope(Dispatchers.Main) from Essenty - Adopt proper Kodein DIAware pattern (remove Inject service locator) - Update platform entry points (Android, iOS, Desktop) to create RootComponent - Delete BaseViewModel, all ViewModel files, and navigation infrastructure - Preserve all business logic, state management, and UI Benefits: - Multiplatform lifecycle management - Type-safe navigation with serializable configs - Better state preservation for nested stacks - Proper dependency injection pattern Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fixed lifecycle issues where child components were reusing parent ComponentContext - Added proper childContext() calls to create isolated lifecycle scopes for child components - Added missing navigation imports (pop, push) to Daily, Health, and Profile components - Removed 'private' modifier from config parameters to allow proper factory usage - Fixed Statistics and Chat components to use proper child contexts in MainComponent This ensures proper cleanup and prevents memory leaks by giving each component its own lifecycle scope. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the JetHabit application from a ViewModel-based architecture to Decompose, a Kotlin Multiplatform library for building reactive and lifecycle-aware components.
Key Changes
LifecycleRegistryandinstanceKeeperMutableStateFlowto Decompose'sMutableValueandValuefor reactive stateTechnical Highlights
DefaultComponentimplementations for all major screens (Dashboard, Habits, Projects, Settings)Files Modified
🤖 Generated with Claude Code