Skip to content

feat(feature/activate): migrate ActivateViewModel to SubmitHandler<Unit> - #2684

Closed
therajanmaurya wants to merge 1 commit into
openMF:store5Migrationfrom
therajanmaurya:feat/store5-c1-activate
Closed

feat(feature/activate): migrate ActivateViewModel to SubmitHandler<Unit>#2684
therajanmaurya wants to merge 1 commit into
openMF:store5Migrationfrom
therajanmaurya:feat/store5-c1-activate

Conversation

@therajanmaurya

@therajanmaurya therajanmaurya commented May 21, 2026

Copy link
Copy Markdown
Member

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.store re-export layer so feature modules consume Store5 submission primitives through core/data and never reach into template.core.base.store.* directly. Then migrates ActivateViewModel as the proof-of-pattern.

Dependency-chain contract (enforced)

core-base/store → core/store → core/data → feature/*
  • core-base/store — framework primitives (template.core.base.store.*), not directly importable from features
  • core/store — app-level customization seam (already exposed api(coreBase.store) in Phase B)
  • core/data — re-exports Store5 abstractions under com.mifos.core.data.store.*. Now correctly routes through api(projects.core.store) instead of api(projects.coreBase.store)
  • feature/* — depends only on core/data (implementation(projects.core.data)) and imports com.mifos.core.data.store.*

Changes (4 files, +76 / -48)

File Change
core/data/build.gradle.kts api(projects.coreBase.store)api(projects.core.store)
core/data/.../store/SubmitTypes.kt NEW — typealias SubmitHandler<R> / SubmitState<R> + CoroutineScope.submitHandler<R>() re-export
feature/activate/build.gradle.kts + implementation(projects.core.data) (no coreBase.store)
feature/activate/.../ActivateViewModel.kt Manual DataState.collectSubmitHandler<Unit> (imported from com.mifos.core.data.store). ActivateUiState and Screen untouched.

Migration template for subsequent waves

  1. feature/<name>/build.gradle.kts: implementation(projects.core.data) (no coreBase.store)
  2. Import com.mifos.core.data.store.SubmitHandler / SubmitState / submitHandler (no template.core.base.store.*)
  3. Replace manual DataState.collect with viewModelScope.submitHandler<R>()
  4. Map submit.state to existing UiState via .map.stateIn to keep the Screen stable
  5. Bridge use-case returns through .first { !Loading } (Flow) or direct check (suspend) + throw on Error

Test plan

  • No template.core.base.store.* imports anywhere under feature/*
  • No implementation(projects.coreBase.store) in any feature/*/build.gradle.kts
  • Activate-client / Center / Group flows behave identically to pre-PR
  • Rapid double-tap is idempotent; sequential calls cancel prior in-flight job

Related

  • Phase B PR: #2683 (merged)
  • Wave 2 follow-up: feat/store5-c2-auth (chained on this branch)

@therajanmaurya
therajanmaurya requested a review from a team May 21, 2026 12:15
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • development

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8d2fd652-ce70-4e75-96f9-063f90c2abab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.
@therajanmaurya
therajanmaurya force-pushed the feat/store5-c1-activate branch from 7b70ef4 to caf4423 Compare May 21, 2026 12:39
@sonarqubecloud

Copy link
Copy Markdown

@therajanmaurya

Copy link
Copy Markdown
Member Author

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

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.

1 participant