feat(feature/activate): migrate ActivateViewModel to SubmitHandler<Unit> - #2684
feat(feature/activate): migrate ActivateViewModel to SubmitHandler<Unit>#2684therajanmaurya wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replaces manual DataState collection with template.core.base.store's
SubmitHandler — a one-shot, idempotent submission executor with built-in
Submitting / Submitted / Failed lifecycle and automatic cancel-prior-job
semantics for sequential calls.
VM:
- Single SubmitHandler<Unit> instead of three viewModelScope.launch blocks
- submit.state mapped to existing ActivateUiState via .map.stateIn so
Screen-side state shape (Initial / Loading / ActivatedSuccessfully /
Error) is unchanged — no Screen changes required
- Per-action success/failure StringResource tracked in two vars set
before each submit; safe because they're written synchronously with
submit.submit { ... } and only read when state transitions to a
terminal value
- ActivateClientUseCase / ActivateCenterUseCase (Flow<DataState<T>>)
bridged via .first { it !is DataState.Loading } + throw on Error
- ActivateGroupUseCase (suspend, returns DataState<Unit> directly) just
checks for Error and throws
build.gradle.kts:
+ implementation(projects.coreBase.store)
This is the migration template for all subsequent mutation-feature
migrations (auth, savings, recurringDeposit, note, checker-inbox-task,
collectionSheet, report, document, loan, client). Each follows the same
shape: introduce a SubmitHandler<R> in the VM, map its state to the
feature's existing UiState, bridge use-case return shapes through
SubmitHandler.submit { ... }, leave the Screen untouched.
7b70ef4 to
caf4423
Compare
|
|
Closing — superseded by the revised end-to-end plan. Re-opening as Wave 1 with full vertical migration (core/network rewrite + BaseViewModel + MutationScreenContent + feature/{ui,di,navigation} layout + per-feature core/data relocation + use-case deletion). See plan: plan-layer/project-plans/mifos-x/mifos-x-field-officer-app/active/store5-adoption/C-features.md |



Summary
Phase C Wave 1 — first feature migration to Store5, establishing the dependency-chain pattern for all 19 subsequent mutation-feature migrations.
Adds the
com.mifos.core.data.storere-export layer so feature modules consume Store5 submission primitives throughcore/dataand never reach intotemplate.core.base.store.*directly. Then migratesActivateViewModelas the proof-of-pattern.Dependency-chain contract (enforced)
core-base/store— framework primitives (template.core.base.store.*), not directly importable from featurescore/store— app-level customization seam (already exposedapi(coreBase.store)in Phase B)core/data— re-exports Store5 abstractions undercom.mifos.core.data.store.*. Now correctly routes throughapi(projects.core.store)instead ofapi(projects.coreBase.store)feature/*— depends only oncore/data(implementation(projects.core.data)) and importscom.mifos.core.data.store.*Changes (4 files, +76 / -48)
core/data/build.gradle.ktsapi(projects.coreBase.store)→api(projects.core.store)core/data/.../store/SubmitTypes.ktSubmitHandler<R>/SubmitState<R>+CoroutineScope.submitHandler<R>()re-exportfeature/activate/build.gradle.kts+ implementation(projects.core.data)(nocoreBase.store)feature/activate/.../ActivateViewModel.ktDataState.collect→SubmitHandler<Unit>(imported fromcom.mifos.core.data.store).ActivateUiStateand Screen untouched.Migration template for subsequent waves
feature/<name>/build.gradle.kts:implementation(projects.core.data)(nocoreBase.store)com.mifos.core.data.store.SubmitHandler/SubmitState/submitHandler(notemplate.core.base.store.*)DataState.collectwithviewModelScope.submitHandler<R>()submit.stateto existing UiState via.map.stateInto keep the Screen stable.first { !Loading }(Flow) or direct check (suspend) + throw on ErrorTest plan
template.core.base.store.*imports anywhere underfeature/*implementation(projects.coreBase.store)in anyfeature/*/build.gradle.ktsRelated
#2683(merged)feat/store5-c2-auth(chained on this branch)