LiveData is part of the Lifecycle library which was designed to help you solve common Android Lifecycle challenges and to make your apps more maintainable and testable.

LiveData is a lifecycle-aware observable. LiveData makes it easy to keep what's showing on screen in sync with the data. Benefits include:

* Lifecycle awareness: LiveData works well with the android lifecycle by only sending updates to UI components that are on screen and automatically removing listeners when a UI component is destroyed.
* Can be returned by Room, to learn more about Room → https://goo.gl/hWAq6R
* Reactive UIs with ViewModel and Data Binding
* Includes basic transformations map and switchMap and MediatorLiveData

LiveData is usually created in a ViewModel class → https://goo.gl/f3gTQx]

The Lifecycle library includes other classes that LiveData works with, including Lifecycle, LifecycleOwner and LifecycleObservable. To learn more about the Lifecycle library, check out → https://goo.gl/pouGCk

Gradle dependencies → https://goo.gl/xD4evT

Also take a look:

Room with a View Codelab [LiveData, ViewModel, Room and the architectural guidance] → http://bit.ly/2FS6YQD
Exposing error and loading state via LiveData → https://goo.gl/fjwccG
ViewModels and LiveData - Patterns and Antipatterns → https://goo.gl/1t3tmL
LiveData with SnackBar, Navigation and other events (the SingleLiveEvent case) → http://bit.ly/2rsmwGl
Subclassing LiveData → https://goo.gl/53Qq52
Using LifecycleObserver → https://goo.gl/e73zTc
Lifecycle codelab → https://goo.gl/OBkIfC
Guide to app architecture → https://goo.gl/tfae2D
Data Binding docs → http://bit.ly/2IjFicG

Watch more Android Jetpack videos here → https://goo.gl/kw8LPv

Subscribe to the Android Developers channel here → https://goo.gl/vLYDU

#AndroidJetpack #jetpack #featured

  • Dr. Superblazer
    Dr. Superblazer 9 месяцев назад Where can i find the same with java examples?
  • Robert Chrzanowski
    Robert Chrzanowski 11 месяцев назад Thanks for the informative video. Keep them coming. Much love for Kotlin.
  • Тимур
    Тимур 3 недели назад A lot of good things about live data, but it's actually very bad. - No normal error handling -- If 'observe' is not used in the 'onCreate' method, then there will be problems when change screen orientation
  • Victor Vicari
    Victor Vicari 11 месяцев назад How about two-way data binding? How the LiveData approach deals with two-way binding?
  • Zhuinden
    Zhuinden 11 месяцев назад Kotlin's been "officially supported language for Android development" since 2017's I/O, it's been a year, surely we can pick it up by now :D
  • Dafle Cardoso
    Dafle Cardoso 11 месяцев назад Someone has a tutorial how can i use Databinding with recyclerview data?
  • Shreyas Waghmare
    Shreyas Waghmare 11 месяцев назад (изменено) I've used Databinding with RecyclerView and Live data in this project (JAVA) : https://github.com/techiespace/Feedback
  • Henry Marvin
    Henry Marvin Год назад While Kotlin may be a good functional object oriented programming language, a vast majority of android developers are Java developers and among them, a lot of them use Java for other purposes as well. This means that all these people(at least the vast majority) are more familiar with the imperative style of programming rather than functional. It would be rather beneficial for the majority if the sample code in the videos are in Java. A change this fast is quiet difficult to adapt to. Thank You.
  • Basanth Verma
    Basanth Verma 11 месяцев назад Try Kotlin bro! There's no coming back once you're in it ;) Java used to be my love, I've programmed in Java for Android and Spring Boot (And I still do for some of my legacy code). But I've started using Kotlin for both Android and Spring Boot in my new Projects now and it feels awesome! I don't think Google is ever going to return to Java. #KotlinIsTheNewJava
  • yassine9871
    yassine9871 11 месяцев назад They are trying to (force) Java developers to learn and use Kotlin. It's a message from google that Kotlin will be the main language for Android Studio in the next few years.
  • Gr3nad3_Man1c
    Gr3nad3_Man1c 11 месяцев назад LiveData is inherently functional, there is no way around that. Kotlin is also far less functional that Scala or Haskell; in fact, I'd say it's closer to Java than to Scala. The Kotlin code in this video is basically Java + some extra syntax sugar.
  • hilman shini
    hilman shini 11 месяцев назад (изменено) true. i cant move from java. tried kotlin but its not suitable for me. i learned so much refactoring techniquewith java, design pattern and anti pattern. but with kotlin it seems weird to use them. and also so many keyword turned to annotations. its confusing for me
  • Zhuinden
    Zhuinden 11 месяцев назад (изменено) LiveData is just something that you can subscribe change listeners to. I thought OBSERVER DESIGN PATTERN is a pattern defined in the Gang of Four book which has OOP patterns? Nothing "functional" about it, especially not "inherently functional".
  • montanax
    montanax 11 месяцев назад How have you not been using Kotlin for at least a year now. Just lol.
  • Francis Thomas
    Francis Thomas 11 месяцев назад (изменено) True man. Its like there are FORCING KOTLIN O NTO US.
  • Kit Mak
    Kit Mak 11 месяцев назад You can always apply your design patterns implementation in java into Kotlin. These kind of language features are not being enforced to you. like for example you could manually create a singleton with lazy initialization and thread-safety(Hope you do not need to look it up everytime) in Kotlin, while there is an easier way to create it by the keyword object. Along with those language features like null-safety and smart casting, etc. It might not be essential for a very senior java developer since it can be reproduced in java with care, but these features enables the developer to avoid the pitfalls and focus on business logic.
  • Younghwan Yoon
    Younghwan Yoon 11 месяцев назад I can't agree more.
  • Kane
    Kane 11 месяцев назад Guys, say ”thank you” to Oracle. It's time to move on to a modern language lol
  • Kane
    Kane 11 месяцев назад Being pushed to learn something new is not always comfortable.
  • Zhuinden
    Zhuinden 11 месяцев назад Seriously though, you can (and typically do) write imperative code with Kotlin. It's not Elm/Haskell/Clojure/Elixir/Scala.
  • Kit Mak
    Kit Mak 11 месяцев назад Imperative programming and OOP, for the most case is good enough to solve many trivial problems, but not being able to model and address some real world problem efficiently. Thats why functional and reactive programming is in trend, because it does help developers solve problems that will be very difficult to solve by a OOP paradigm, which improves ease of maintenance and code readability.
  • TZCoder
    TZCoder 11 месяцев назад I like Java!
  • Zhuinden
    Zhuinden 11 месяцев назад I used to like Java, but Kotlin is better.
  • Sébastien Cayetanot
    Sébastien Cayetanot 5 месяцев назад As developer, we are supposed to be adaptable. We can’t rely on one language and just don’t want to look at something else. In addition, google pushing on kotlin this is why they will use example in kotlin
  • Muhammad Jamal
    Muhammad Jamal 11 месяцев назад Can LiveData hold many transformations at the same time?
  • Zhuinden
    Zhuinden 11 месяцев назад Transformations are just doing some magic in the background using a MediatorLiveData, so sure!
  • Tanuj Sareen
    Tanuj Sareen 11 месяцев назад can ViewModel + LiveData be used in firebase realtime database ??
  • Zhuinden
    Zhuinden 11 месяцев назад Nobody stops you from posting the latest value to the LiveData when you receive a change notification from Firebase
  • Shreyas Waghmare
    Shreyas Waghmare 11 месяцев назад (изменено) What would be the java equivalent for the line binding.viewmodel at 1:55?
  • Shreyas Waghmare
    Shreyas Waghmare 11 месяцев назад Got it! binding.setVariable(BR.myViewModel,myViewModel);
  • Sieński Witold
    Sieński Witold 11 месяцев назад LiveData + databinding is huge help :)
  • Gabriel Monteiro Fernandes
    Gabriel Monteiro Fernandes 8 месяцев назад Please, provide us a good and complete sample of all of this.
  • Shehan Abid
    Shehan Abid 11 месяцев назад All these great new features coming but examples on kotlin, becoming really hard to relate to this. been developing android apps for years but still, seeing the unfamiliar code of kotlin makes it kinda harder to instantly pick the concept and grasp it. Along with learning the concept i feel like i have to learn a whole language as well, making things more complicated for no reason.
  • Kit Mak
    Kit Mak 11 месяцев назад (изменено) Getting out of your comfort zone is the real difficulty you have, while learning Kotlin is easier than you thought. It's language feature actually makes it easier for developer to follow cleaner coding style like DSL, which kind of make it unifies with those popular android library like retrofit and Room.
  • Lim Harry
    Lim Harry 11 месяцев назад 黄渤…………
  • M.Poorvesh Muthraman
    M.Poorvesh Muthraman 8 месяцев назад These are a life saver!!!!!!!!! <3
  • Mark Scooby
    Mark Scooby 9 месяцев назад You're the best.
  • baturay Alhaj Ahmad
    baturay Alhaj Ahmad 8 месяцев назад (изменено) //meanwhile == thread, ?
  • Rakesh Kumar
    Rakesh Kumar 11 месяцев назад Thank you sir
  • Gordon Foster
    Gordon Foster 11 месяцев назад Madam.
  • Rakesh Kumar
    Rakesh Kumar 11 месяцев назад Gordon Foster thank you madam
  • Rakesh Kumar
    Rakesh Kumar 11 месяцев назад OK thank you madam
  • Mahendra Rajdhami
    Mahendra Rajdhami 2 месяца назад Thanks.
  • Atakan Çoban
    Atakan Çoban 7 месяцев назад Java please :)