Skip to content
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

04-live-data-and-view-model #11

Open
wants to merge 1 commit into
base: 03b-advanced-data-binding
Choose a base branch
from

Conversation

Serchinastico
Copy link
Contributor

This PR is not meant to be merged

This is how to use LiveData and ViewModel components:

  • Replace old presenters by the new Androidx ViewModel compoments. They are created through a ViewModelFactory that we are redefining just so that we can inject our own dependencies on them.
  • All visible properties of view models are now LiveData. That means that they can be observed by the UI and update them on the fly when editing.
  • The async model has changed now that we are using LiveData in all layers. We now call our use cases on the UI thread and do the context change on data sources only when required. LiveData has really strong prerequisites to work with it and the threading model is everything but crystal clear, so we are playing it defensively by always posting values instead of changing them right away and keeping ourselves as long on the UI thread as possible as some functions like addSource from MediatorLiveData will behave oddly otherwise.

Copy link

@tonilopezmr tonilopezmr left a comment

Choose a reason for hiding this comment

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

Well done 👍

Copy link
Member

@davideme davideme left a comment

Choose a reason for hiding this comment

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

🚀

@Serchinastico Serchinastico changed the title Add LiveData & ViewModels 04-live-data-and-view-model Feb 6, 2019
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch 3 times, most recently from e5b3c72 to 592849a Compare February 6, 2019 14:21
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch 3 times, most recently from a20a140 to 52e37d2 Compare March 15, 2019 17:31
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch 2 times, most recently from 5a956ff to e80f6af Compare March 15, 2019 17:35
Migrate edit super hero screen

Migrate main screen to view model

WIP
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