Skip to content

Moves ReactiveStateViewModel from FC to shared module. #10718

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

carlosmuvi-stripe
Copy link
Collaborator

@carlosmuvi-stripe carlosmuvi-stripe commented Apr 24, 2025

Summary

This PR moves two utility classes used in FC to ui-core to improve state management across our ViewModels:

  • ReactiveStateViewModel<S>: A base ViewModel class that manages UI state through StateFlow with built-in support for async operations
  • Async<T>: A type-safe representation of asynchronous operation states (uninitialized, loading, success, failure)

Motivation

Our current ViewModels often implement similar patterns for:

  • Maintaining and exposing UI state
  • Handling loading, success, and error states for async operations
  • Transforming results into state updates

These classes standardize these patterns and have been proven useful in FC, reducing boilerplate and enforcing consistent state handling across the codebase.

Changelog

*
* @param T The type of the value that the operation will produce.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same class that existed in FC, but better documented.

* @param initialState The initial state to start with
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
abstract class ReactiveStateViewModel<S>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same class that existed in FC, but better documented.

@carlosmuvi-stripe carlosmuvi-stripe changed the title Moves StateViewModel to ui-core. Moves ReactiveStateViewModel from FC to shared module. Apr 24, 2025
Copy link
Contributor

github-actions bot commented Apr 24, 2025

Diffuse output:

OLD: identity-example-release-base.apk (signature: V1, V2)
NEW: identity-example-release-pr.apk (signature: V1, V2)

          │          compressed          │         uncompressed         
          ├───────────┬───────────┬──────┼───────────┬───────────┬──────
 APK      │ old       │ new       │ diff │ old       │ new       │ diff 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
      dex │   2.1 MiB │   2.1 MiB │  0 B │   4.3 MiB │   4.3 MiB │  0 B 
     arsc │     1 MiB │     1 MiB │  0 B │     1 MiB │     1 MiB │  0 B 
 manifest │   2.3 KiB │   2.3 KiB │  0 B │     8 KiB │     8 KiB │  0 B 
      res │ 302.9 KiB │ 302.9 KiB │  0 B │   457 KiB │   457 KiB │  0 B 
   native │   6.2 MiB │   6.2 MiB │  0 B │  15.8 MiB │  15.8 MiB │  0 B 
    asset │   7.7 KiB │   7.7 KiB │  0 B │   7.4 KiB │   7.4 KiB │  0 B 
    other │  95.7 KiB │  95.7 KiB │ -7 B │ 183.5 KiB │ 183.5 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.8 MiB │   9.8 MiB │ -7 B │  21.8 MiB │  21.8 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 20668 │ 20668 │ 0 (+0 -0) 
   types │  6493 │  6493 │ 0 (+0 -0) 
 classes │  5259 │  5259 │ 0 (+0 -0) 
 methods │ 31489 │ 31489 │ 0 (+0 -0) 
  fields │ 18221 │ 18221 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3646 │ 3646 │  0
APK
   compressed    │  uncompressed   │                     
──────────┬──────┼──────────┬──────┤                     
 size     │ diff │ size     │ diff │ path                
──────────┼──────┼──────────┼──────┼─────────────────────
 29.2 KiB │ -4 B │ 64.6 KiB │  0 B │ ∆ META-INF/CERT.SF  
  1.2 KiB │ -3 B │  1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA 
──────────┼──────┼──────────┼──────┼─────────────────────
 30.4 KiB │ -7 B │ 65.8 KiB │  0 B │ (total)

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.

3 participants