Commit 7b70ef4
feat(feature/activate): migrate ActivateViewModel to SubmitHandler<Unit>
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.1 parent dd14cda commit 7b70ef4
2 files changed
Lines changed: 48 additions & 47 deletions
File tree
- feature/activate
- src/commonMain/kotlin/com/mifos/feature/activate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
Lines changed: 47 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | | - | |
43 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
59 | 58 | | |
60 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
77 | 73 | | |
| 74 | + | |
78 | 75 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
88 | 85 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
93 | 92 | | |
| 93 | + | |
94 | 94 | | |
0 commit comments