-
Notifications
You must be signed in to change notification settings - Fork 617
feat(core:domain): Migrate to KMP #2350
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
base: kmp-impl
Are you sure you want to change the base?
Conversation
core/domain/build.gradle.kts
Outdated
@@ -8,37 +8,67 @@ | |||
* See https://github.com/openMF/android-client/blob/master/LICENSE.md | |||
*/ | |||
plugins { | |||
alias(libs.plugins.mifos.android.library) | |||
alias(libs.plugins.mifos.kmp.library) | |||
alias(libs.plugins.mifos.android.library.jacoco) | |||
alias(libs.plugins.mifos.android.koin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for android. Remove this and include alias(libs.plugins.mifos.kmp.koin)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented the suggestion. Thanks
alias(libs.plugins.jetbrainsCompose) | ||
alias(libs.plugins.compose.compiler) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this!?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are added for the following code in build.gradle of core:domain:
compose.resources {
publicResClass = true
generateResClass = always
packageOfResClass = "core.domain.generated.resources"
}
): Flow<Resource<GenericResponse>> = callbackFlow { | ||
): Flow<Resource<GenericResponse>> = flow { | ||
try { | ||
trySend(Resource.Loading()) | ||
emit(Resource.Loading()) | ||
val response = activateRepository.activateGroup(groupId, groupPayload) | ||
trySend(Resource.Success(response)) | ||
emit(Resource.Success(response)) | ||
} catch (exception: Exception) { | ||
send(Resource.Error(exception.message.toString())) | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@biplab1 don't use try-catch
inside flow. Take reference from LoginUseCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look into it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have implemented your suggestion.
# Conflicts: # core/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/DeleteClientAddressPinpointUseCase.kt # core/domain/src/main/java/com/mifos/core/domain/useCases/GetAllLoanUseCase.kt
try { | ||
emit(Resource.Loading()) | ||
emit(Resource.Loading()) | ||
}.flatMapLatest { | ||
repository.getCentersGroupAndMeeting(centerId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when return type is flow, i dont think we need useCases, use it directly in the viewmodel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are returning flow in every useCases. I don't think I understand your statement. Could you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@biplab1 since repository.getCentersGroupAndMeeting(centerId)
already returns flow, we do not need to convert it to flow again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point now. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are combining two flows into a single flow using zip
# Conflicts: # core/domain/src/androidMain/kotlin/com/mifos/core/domain/useCases/GroupsListPagingDataSource.android.kt
|
||
operator fun invoke(): Flow<Resource<SavingProductsAndTemplate?>> = | ||
flow { | ||
try { | ||
emit(Resource.Loading()) | ||
|
||
val savingProductsAndTemplate = coroutineScope { | ||
val savingsAccount = async { repository.savingsAccounts() } | ||
val template = async { repository.savingsAccountTemplate() } | ||
|
||
SavingsProductsAndTemplate( | ||
savingsAccount = savingsAccount.await(), | ||
template = template.await(), | ||
) | ||
} | ||
emit(Resource.Success(savingProductsAndTemplate)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use combine instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look into it. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have implemented your suggestion. Thanks again
Fixes - Jira-#410
Didn't create a Jira ticket, click here to create new.
Please Add Screenshots If there are any UI changes.
Please make sure these boxes are checked before submitting your pull request - thanks!
Run the static analysis check
./gradlew check
orci-prepush.sh
to make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.