A Compose state of mind: Using Jetpack Compose's automatic state observation

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ย. 2024

ความคิดเห็น • 36

  • @arjangap2551
    @arjangap2551 ปีที่แล้ว +2

    Amazing video. He has a deep understanding of the subject and because of that he can transform his knowledge. Give him a raise ❤

  • @HaSeebpjr01
    @HaSeebpjr01 8 หลายเดือนก่อน

    Every important aspects of compose in one video, excellent work and clear explanations. Thank you so much ❤❤

  • @AriAp-mh3bf
    @AriAp-mh3bf ปีที่แล้ว +1

    Amazing presentation. one of the best I've seen from Android Developers channel. please make more videos like this.

  • @ZeDzszedl
    @ZeDzszedl 3 ปีที่แล้ว +31

    Very good video. Docs on state hoisting in compose are lacking real life examples and this video clarify some concepts. Thanks!

  • @purpledaysable
    @purpledaysable 3 ปีที่แล้ว +5

    Yes. Absolutely- and as usual, you've helped me enter "A Compose State Of Mind".... Thank You for walking me through, as running through important steps is always a waste of time.

  • @DavidNitzscheBell
    @DavidNitzscheBell ปีที่แล้ว +2

    parts of this are useful, but many more are not explained enough or with real examples. very convoluted. hopefully the codelab will make stuff clearer.

  • @reyalfiesenajon7908
    @reyalfiesenajon7908 2 ปีที่แล้ว

    salamat ss palabas na ito ang ganda pakingan

  • @mikeshilovski1512
    @mikeshilovski1512 2 ปีที่แล้ว +1

    awesome presentation, thanks a lot

  • @Mrdresden
    @Mrdresden 3 ปีที่แล้ว +2

    Great stuff! These tutorials are essential for getting into this complete new way of doing things. So plz keep it up

  • @pigua7705
    @pigua7705 ปีที่แล้ว

    Good job

  • @chitho1987
    @chitho1987 ปีที่แล้ว +1

    17:58 He means the DI library Hilt not Field

  • @demauromark
    @demauromark 3 ปีที่แล้ว +4

    “Simplicity is the soul of efficiency.” - Austin Freeman. It would be great if you show some coding tutorials to clearly understand the concepts.

  • @tripabroad8918
    @tripabroad8918 2 ปีที่แล้ว

    Preview isn't drawn when viewModel has some params. Did anyone have this issue?

  • @NguyenTran-uv6mu
    @NguyenTran-uv6mu 2 ปีที่แล้ว +1

    I 'm still confusing about UI-element state vs screen state

    • @AndroidDevelopers
      @AndroidDevelopers  2 ปีที่แล้ว

      Hello, Nguyên! Take a look at the link below for more information about UI layers.
      goo.gle/3uXxOTP
      We hope this helps!

  • @gmk57
    @gmk57 3 ปีที่แล้ว

    Passing parameters to remember() (see code around 14:00) means that JetsnackAppState will be reset whenever any of its dependencies changes, right? It also won't survive configuration change or process recreation. Can lead to bugs if JetsnackAppState contains its own (not derived from dependencies) state.

    • @manuelvicnt
      @manuelvicnt 3 ปีที่แล้ว

      Hi! Yeah, that's the idea, generally, you want to recreate the state holder if the dependencies change. If you don't do that, you might be using old instances of certain types that could potentially lead to memory leaks. As mentioned in your other comment, use `rememberSaveable` to make state survive config changes or process recreation

  • @hugovelarde288
    @hugovelarde288 2 ปีที่แล้ว

    If I want to tracked an image not a number, how do I do?

  • @SAMathlete
    @SAMathlete 2 ปีที่แล้ว

    I'm excited to learn this framework so that I too can charge people $12.99 for an ice cream sandwich.

  • @gmk57
    @gmk57 3 ปีที่แล้ว

    When LazyList's scroll position and expanded items are stored in CartState (19:09), they will be cleared on navigating to another screen & back, correct? That won't look good from UX perspective.

    • @manuelvicnt
      @manuelvicnt 3 ปีที่แล้ว +1

      You can `rememberSaveable` CartState if there's data you want to preserve across process and activity recreation

    • @gmk57
      @gmk57 3 ปีที่แล้ว

      @@manuelvicnt Thanks for clarification. But fragment's view is also destroyed while in the back stack, AFAIK. What about Compose & its state?

    • @remerico
      @remerico 2 ปีที่แล้ว

      @@gmk57 Compose rememberSaveable states are saved on the Fragment/Activity saved instance bundle, on the same place where onSaveInstanceState is used

  • @gmk57
    @gmk57 3 ปีที่แล้ว

    Is it a good idea to call collectAsState() inside a composable function (17:05)? This conversion function will be re-executed on every recomposition.

    • @manuelvicnt
      @manuelvicnt 3 ปีที่แล้ว +4

      Hello! `collectAsState` is remembered and it's not re-executed on every recomposition. New values emitted into the flow will cause recompositions though. Hope this clarifies few things!

    • @eliazarcampos3202
      @eliazarcampos3202 3 ปีที่แล้ว

      @@manuelvicnt por que

    • @eliazarcampos3202
      @eliazarcampos3202 3 ปีที่แล้ว

      Kaon sc7210

    • @remerico
      @remerico 2 ปีที่แล้ว

      The composable function will only be recomposed when the collectAsState() value changes, Compose is smart enough to skip recomposing parts of the UI where the states did not change.

  • @dp1927
    @dp1927 3 ปีที่แล้ว

    All I want is the nav controller availability in vm :(

  • @reyalfiesenajon7908
    @reyalfiesenajon7908 2 ปีที่แล้ว

    its ok

  • @赵梦-k5x
    @赵梦-k5x 2 ปีที่แล้ว

    牛蛙牛蛙

  • @rubyh4184
    @rubyh4184 3 ปีที่แล้ว

    This doesnt seemed to follow OOP principle at all with all those remember keywords. It is a function that magically store state somewhere you dont know using remember keyword. Flutter does this cleanly with widget as object instead of function.

    • @NohusBluxome
      @NohusBluxome 3 ปีที่แล้ว +6

      Compose is not OO, it's declarative programming. OOP principles are irrelevant here.

    • @remerico
      @remerico 2 ปีที่แล้ว +1

      Compose is comparable to using XML / Data binding, UI frameworks do not benefit at all from object-oriented programming. I'm glad Google realized this and made Compose fully declarative. You might have a point with the "magic" remember keyword, but you do not have to use it, just can also put your state in a view model, it is only a convenience feature to make things simpler.

    • @firstnamelastname-oy7es
      @firstnamelastname-oy7es ปีที่แล้ว

      The code passed in the lambda to the remember function is executed only on initial composition, and not in re-composition, unless the any of the optional key parameters to the remember function have changed, which will cause the lambda to be re-executed.

    • @mubaraknative
      @mubaraknative 5 หลายเดือนก่อน

      OOP is not a principal tho, it is a one type of paradigm in a programming languages