-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Switch to compose state and kotlin flows - 2. iteration #287
Switch to compose state and kotlin flows - 2. iteration #287
Conversation
fe4805f
to
97be8fb
Compare
97be8fb
to
a34362e
Compare
201a50a
to
b252c4c
Compare
9bc712e
to
e399a57
Compare
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 not commented on everything, but as stated, use Flow
or Compose states as:
var variable by mutableStateOf(...)
private set
And then in the composable, just use =
:
val variable = model.variable
And set all values from the viewmodels through setters as needed.
app/src/main/java/at/bitfire/icsdroid/model/CreateSubscriptionModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/at/bitfire/icsdroid/model/EditSubscriptionModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/at/bitfire/icsdroid/model/SubscriptionSettingsModel.kt
Show resolved
Hide resolved
app/src/main/java/at/bitfire/icsdroid/ui/views/CalendarListActivity.kt
Outdated
Show resolved
Hide resolved
e399a57
to
114956d
Compare
I think this should be it for now? Should turn a lot prettier with the 3rd and 4th iterations. |
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.
Just one state missing 😉 (see unresolved conversation)
Purpose
Replacing LiveData with compose state and flows, will in the future hopefully prevent the issues that came with LiveData. Also it makes for easier integration with DAVx5.
Short description
This is the 2. Iteration of the switch from LiveData to compose state and kotlin flows. See the 1. iteration here.
The 1. Iteration took care of the Database Access Objects. It deprecated LiveData returning methods and added their respective Flow returning variants.
In this 2. iteration models and activities are rewritten, by replacing all LiveData usages in both models and activities, excluding any 1. iteration DAO changes, since this PR would grow too big otherwise.
The 3. iteration will take care of using the new Flow returning methods in DAOs and remove the last remaining LiveData usages.
This PR:
CredentialsModel
andSubscriptionSettingsModel
since their flow type members are merged inEditCalendarActivity
and it is not possible to merge compose states, to my knowledge. In any case, the declaration ofmodelsDirty
needs special attention.uiState
data classes with private set where possibleChecklist