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

View Model Refactor Concept - Shared Interface #206

Closed
wants to merge 2 commits into from

Conversation

brady-aiello
Copy link
Contributor

Summary

The code in NativeViewModel and MainViewModel (Android) is nearly identical.

Fix

We can make them both implement an interface with mostly default functions, and keep platform-specific code minimal. Platform-specific stuff:

  • the CoroutineScope for each
  • exposing Flows through callbacks for iOS

Testing

  • ./gradlew :app:build
  • ./gradlew :shared:build
  • xcodebuild -workspace ios/KaMPKitiOS.xcworkspace -scheme KaMPKitiOS -sdk iphoneos -configuration Debug build -destination name="iPhone 8"
  • manual testing

[Summary]
There is another way to handle state than the previous 2 ways, and I
wanted the best aspects of both of them:
- mutually exclusive states
- No nullability
- Easy reasoning at the View level

[Fix]
Make DataState a sealed class, but give each a loading Boolean

[Testing]
- `./gradlew :app:build`
- `./gradlew :shared:build`
- `xcodebuild -workspace ios/KaMPKitiOS.xcworkspace -scheme KaMPKitiOS
    -sdk iphoneos -configuration Debug build -destination name="iPhone 8"`
- manual testing
[Summary]
The code in NativeViewModel and MainViewModel (Android) is nearly
identical.

[Fix]
We can make them both implement an interface with mostlydefault
functions, and keep platform-specific code minimal.

[Testing]
- `./gradlew :app:build`
- `./gradlew :shared:build`
- `xcodebuild -workspace ios/KaMPKitiOS.xcworkspace -scheme KaMPKitiOS
    -sdk iphoneos -configuration Debug build -destination name="iPhone 8"`
- manual testing
@KevinSchildhorn KevinSchildhorn changed the title [Issue-0000] Adding KMM ViewModel View Model Refactor Concept - Shared Interface Oct 5, 2021
@kpgalligan
Copy link
Contributor

PR #238 is a merge of the view model concept PRs. Closing this one.

@kpgalligan kpgalligan closed this Mar 18, 2022
@kpgalligan kpgalligan deleted the brady-aiello/shared-viewmodel branch March 20, 2022 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants