Fun with LiveData (Android Dev Summit '18)

Sdílet
Vložit
  • čas přidán 6. 11. 2018
  • LiveData is a simple observable data holder that is aware of the lifecycle of the observers. It was designed to avoid memory leaks and null pointer exceptions between an activity or fragment and a ViewModel.
    However, you can also use LiveData beyond the ViewModel. Components like Room or Workmanager also expose LiveData observables, and you can make your own data sources lifecycle-aware.
    In this talk, we'll deep dive into patterns with LiveData such as the different types of transformations (map, switchMap and MediatorLiveData), handling events and building reactive architectures as well as common antipatterns and code-smells to avoid.
    Links:
    LiveData blogs → bit.ly/2PUpnWd
    Samples → bit.ly/2qzKbDN
    I/O app → bit.ly/2Ov1Vd3
    Presented by: Jose Alcérreca & Yigit Boyar
    Android Dev Summit '18 all sessions playlist → bit.ly/ADS18-Sessions
    Subscribe to the Android Channel! → bit.ly/AndroidDevs1
    #AndroidDevSummit" event: Android Dev Summit 2018; re_ty: Publish; product: Android - Jetpack; fullname: Jose Alcérreca, Yigit Boyar;
  • Věda a technologie

Komentáře • 58

  • @ioanesharvadze707
    @ioanesharvadze707 Před 5 lety +2

    Very good points in this talk!
    It's interesting to see when one can use Coroutines Channel API and when LiveData.

  • @mdalikazi
    @mdalikazi Před 5 lety +1

    Very good summary of the new MVVM!

  • @witoldsienski1709
    @witoldsienski1709 Před 5 lety

    Complete presentation :)

  • @b.k4142
    @b.k4142 Před 5 lety

    Hi every one i don't understand transformation map switch it s behind the scene what happened in android studio! thanks

  • @sleepydev4700
    @sleepydev4700 Před 3 lety +2

    what does it mean by creating live data every time, so basically it's not a good way to have a field of livedata in repository?

  • @damolaOnikoyi
    @damolaOnikoyi Před 2 lety

    thank you for this

  • @user-kj1vp1tt9u
    @user-kj1vp1tt9u Před 3 lety

    Is the end telling us that ,we don't need use the livedata to in reposity to convert data ?

  • @otischen8773
    @otischen8773 Před 5 lety +3

    Subtitle says "If you try to scale, it is just not going to work" at 18:18. Is that means livedata can not handle UI very well when the scale is big?

    • @JoseAlcerreca
      @JoseAlcerreca Před 5 lety +2

      Yeah, LiveData was designed for View-ViewModel. Transformations were added for simple combination of LiveDatas. If you are trying to combine dozens of data sources with different lifespans you might to look at something else.

    • @Zhuinden
      @Zhuinden Před 5 lety +7

      What? No, by scaling they meant that "scaling it beyond the responsibility it was designed for", namely holding the last value and providing it to the observer (Activity/Fragment). So like, don't try to model network requests with LiveData with some kind of LiveDataCallAdapter because why would you even do that

  • @devdeeds
    @devdeeds Před 3 lety

    Thank you

  • @MuhammadAmir-mf9xt
    @MuhammadAmir-mf9xt Před 5 lety

    that awesome..

  • @laujimmy3866
    @laujimmy3866 Před 4 lety

    @3:22 it's not in an active state, like a onStop

  • @mr.w483
    @mr.w483 Před 4 lety +5

    Love the opening song, might I have its name :D

  • @jazzthechamp2105
    @jazzthechamp2105 Před 5 lety

    Helloo i have one question.,
    What is the need of ViewModel if we can handle configuration changes by writing a single line of code in manifest file i.e configurationChanges”orientation|keyboardHidden”..

    • @HaiderAli-co9jl
      @HaiderAli-co9jl Před 5 lety

      That's not recommended, you can look at the android docs. ViewModel is the part of the well accepted android architecture and code is more organized and debugable (don't know if it's a word or not ;) ).

    • @MrLeeKnees
      @MrLeeKnees Před 4 lety +3

      Because there are lots of ways the system can destroy your activities apart from device rotation, etc.

  • @mostasimbillah
    @mostasimbillah Před 5 lety

    How can I get the slide?

  • @tarrymasters1242
    @tarrymasters1242 Před 5 lety

    So simply I got confused. If only a written text or a step procedure for tose of us whot are required to set up for the program on a seperate page, which hearing or language program to allow viewing every page.

    • @mujtabac5
      @mujtabac5 Před 5 lety +1

      You can imagine now how things can get so confused on a job interview when someone confuses exactly the same way these two nerds just did. Typical Google interviewers!

  • @tarrymasters1242
    @tarrymasters1242 Před 5 lety +2

    We are always developing.

    • @senab
      @senab Před 5 lety +1

      Always.

  • @aravindhanathmanathan2489

    Please ..Anyone can me explain the Transformation.swtichMap?

  • @RaulGerardoHuertasPaiva

    this was supposed to be fun... :P

  • @bessermt
    @bessermt Před 4 lety

    15:20 Why would observers be able to change something that is immutable?

    • @mochadwi
      @mochadwi Před 4 lety +1

      maybe he meant, "the observer can't change it"

  • @dipeshmalkar6046
    @dipeshmalkar6046 Před 3 lety +2

    I think library like room should not provide support to LIVE DATA as return type. As most of the time developer use them with viewmodel where lifecycle doesn't matter. A simple observer pattern design would be good enough

    • @hugovera1540
      @hugovera1540 Před rokem +1

      they like to make it as harder and convoluted as possible.

  • @anirudhganesh7714
    @anirudhganesh7714 Před 4 lety +5

    shows 4 lines of code and calls it simple. Me the noobie watches and blinks

    • @derickflorian4724
      @derickflorian4724 Před 3 lety

      I'm sure you figured it out by now, Anirudh, but I'm struggling to learn this concept! This video was extremely helpful though and hopefully I'm a little closer to grasping it.

  • @kattaritechnologies1592

    2:58 the second guy contradict the first guy, and he runs in shame.

  • @linuxhai
    @linuxhai Před 5 lety +1

    LiveData

  • @BoobalanMunusamy
    @BoobalanMunusamy Před 4 lety +1

    I don't understand why Google making observable so complicated using LiveData and etc.. Look at C# WPF , how easily they were implemented this MVVM pattern. Even Xamarin supports such a observable design pattern without any hurdle. But, Google is messing this up with many complicated API.
    How this ViewModel works with Databinding concept ?

    • @emmanuelmtali1594
      @emmanuelmtali1594 Před 4 lety +1

      You can pass your ViewVodel to your DataBinding object on your Activity/Fragment. In your layout you can access public function or variables of your ViewModel you just passed including the LiveData

  • @tarrymasters1242
    @tarrymasters1242 Před 5 lety

    The Android is a tool?

  • @tarrymasters1242
    @tarrymasters1242 Před 5 lety

    Developers where else are we, me or I?

  • @SnoopyDoofie
    @SnoopyDoofie Před 5 lety +1

    Stick with RxJava.

    • @AryanKumar-no5jf
      @AryanKumar-no5jf Před 5 lety

      LiveData is a data holder, it's not for advanced business logic.

  • @mukund_kn
    @mukund_kn Před 5 lety +8

    They are using Kotlin everywhere. I get that because they provided the first class support. But that doesn't mean to ignore the Java right? I am a Java developer and when they use Kotlin tool for explaining stuff, I get bored. I just don't understand the flow of Kotlin, it's just not easy to read. At least they should use both Java and Kotlin in these kinds of presentation. So many peoples are still depending on Java and Google should not act like they don't care about Java developers.

    • @Zhuinden
      @Zhuinden Před 5 lety +10

      Kotlin fits much better on slides, it's easier to just learn how to read Kotlin.

    • @KyleFalconer1
      @KyleFalconer1 Před 5 lety +4

      Google has said (as of 2019) that they're going to be using Kotlin as the primary language for Android. You should expect this going forward. It's not going away.

    • @abdusalam3ar
      @abdusalam3ar Před 5 lety +1

      Totally agree. We have to learn kotlin now in order to understand what they are talking about. There is even new code labs that are only in kotlin

    • @mrarcticaaa1101
      @mrarcticaaa1101 Před 4 lety +1

      Kotlin is quite easy and google has free courses on udacity, even for those with java background since it's easier for them.

    • @pxnx
      @pxnx Před 4 lety

      Kotlin is much better and simpler. Why keep on Java?

  • @watfordjc
    @watfordjc Před 5 lety +2

    Telling me loaders are deprecated, and then only using Kotlin to try and explain LiveData, means I can't comprehend LiveData. I will never understand Kotlin because it removes all the syntax and clues my ASD brain needs to work out what code is doing, meaning unlike C, Java, JS, C#, Python, PHP, etc. I cannot make any sense of what the meaningless gibberish on the slides is trying to describe.
    Use pseudocode in your next talk if you think the subject is important enough to be understood by all, because Google has done a crap job at explaining why l should no longer use an AsyncTaskLoader to load JSON over HTTPS that must *not* be stored or cached.

    • @Existentialkev
      @Existentialkev Před 5 lety +4

      Wow...
      1st Kotlin is not complicated at all, give it the good ol' college try. Hearing you complain about it lack the useless verbosity of Java shows me you haven't given it a fair chance.
      2nd Jesus H Chris if you are still using AsyncTask to handle IO operations you are years behind on android best practices... Please do some googling and you will find possibly hundreds of articles about why you should ditch AsyncTask
      If you are actually a professional android developer and harboring these views, I might have a heart attack

    • @kolboch
      @kolboch Před 5 lety +2

      @@Existentialkev You are wrong there cowboy. If you think that everyone works with start up projects and can easily use fresh 1 month old tech stack you are very wrong, don't attack this guy because of async task, maybe he can't add 5Mb of libraries just to make single api call...
      Please respect other, there are many different situations and you shouldn't judge just from your perspectives.
      About Kotlin I agree though, pause the video Watford and you will see it's the same like java, just more simple and elegant to write what you want if done properly ;)

    • @DriveToSuccessTalks
      @DriveToSuccessTalks Před 2 lety

      @@kolboch right 👍

  • @tarrymasters1242
    @tarrymasters1242 Před 5 lety

    google is attempting me to upgrade for my photos, for a profit most are those I had received from you tube, i am only taking a few photoes and had not descivbed theem.

  • @technics6215
    @technics6215 Před rokem

    Lol it was in 2018 and there is still findViewById and that guy who was talking about studying computer science to type "findViewById" :D

  • @kassadinorz9855
    @kassadinorz9855 Před 5 lety

    the library has million transformations means ?

    • @mightyfinner
      @mightyfinner Před 5 lety +2

      I guess he was referencing Rx transformations