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.

@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 4da947e to 6ccc843 Compare February 5, 2019 12:30
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 force-pushed the 04-live-data-and-view-model branch from 6ccc843 to eaaadc0 Compare February 5, 2019 19:06
@Serchinastico Serchinastico changed the title Add LiveData & ViewModels 04-live-data-and-view-model Feb 6, 2019
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from 7caf147 to f2cd3e3 Compare February 6, 2019 10:10
@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 from f2cd3e3 to b508ca6 Compare March 15, 2019 11:31
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 592849a to 2a59248 Compare March 15, 2019 11:32
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from b508ca6 to f21ea81 Compare March 15, 2019 16:38
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 2a59248 to d9da96b Compare March 15, 2019 16:38
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from f21ea81 to 3f37772 Compare March 15, 2019 16:54
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from d9da96b to 7482884 Compare March 15, 2019 16:55
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from 3f37772 to 6e0488d Compare March 15, 2019 16:59
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 7482884 to 6100eb2 Compare March 15, 2019 17:02
@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
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from 52e37d2 to 5ce5d5b Compare March 15, 2019 17:44
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from e80f6af to 2fa910d Compare March 15, 2019 17:45
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from 5ce5d5b to 1f02122 Compare March 15, 2019 18:39
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 2fa910d to 46cf2b2 Compare March 15, 2019 18:42
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from 1f02122 to c4f1224 Compare May 21, 2019 10:28
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 46cf2b2 to 7ac91df Compare May 21, 2019 10:29
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from c4f1224 to 667bf7d Compare May 21, 2019 15:47
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from 7ac91df to dd31b7c Compare May 21, 2019 15:53
@Serchinastico Serchinastico force-pushed the 03b-advanced-data-binding branch from 667bf7d to cd94eca Compare May 22, 2019 16:40
Migrate edit super hero screen

Migrate main screen to view model

WIP
@Serchinastico Serchinastico force-pushed the 04-live-data-and-view-model branch from dd31b7c to e3f613c Compare May 22, 2019 16:44
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