State in Jetpack Compose

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 113

  • @jonathancampos8929
    @jonathancampos8929 2 года назад +24

    Wow! Thanks for this presentation, the speakers did an incredible job together. Excited to watch new content with you two folks

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      Hey, Jonathan! We think so too! It's always a pleasure to see how excited viewers are for more content 🙂

    • @hindpal3551
      @hindpal3551 2 года назад

      @@AndroidDevelopers p☺️

  • @MuhammadWaheed-r4l
    @MuhammadWaheed-r4l 9 месяцев назад

    After working 6 months in compose. Today I Understand how to properly handle UI state in Compose . Thanks to the dev team 👍. Previously I violate the single source of truth by passing ViewModel down to composables.

  • @anaibrahim4361
    @anaibrahim4361 Год назад

    I truly didn't know how to thank you for giving this to us for free.

  • @ZachKlippenstein
    @ZachKlippenstein 2 года назад +25

    I like that Manuel’s intro was stateful 😂

  • @isabelporto5243
    @isabelporto5243 2 года назад +8

    Ale you are the best! Thank you so much for the presentation.

  • @anibalbastiass
    @anibalbastiass 2 года назад +7

    Great workshop! I really like the clear explanation and solved my doubts about the Composable States. You rock guys!

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      Thanks for the wonderful feedback; we're glad it was helpful! 😁

  • @chtiboss78
    @chtiboss78 2 года назад +16

    Great presentation.
    I like the cristal clear workshop, common developer errors, and dynamism of the presentation.
    I am impatient to see another presentation like this, based on codelabs.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      Happy to hear that the tutorial was helpful, Chti. You can also check out the codelab for Using state in Jetpack Compose, as seen in the video here: goo.gle/3ssNnBO

  • @ChicoRasia_CLabs
    @ChicoRasia_CLabs Год назад +4

    Great job! I've been getting even more out of the codelabs that have this type of presentation. It helps to draw attention to the important details in the step by step guide. Keep it up!

  • @YairCarreno
    @YairCarreno 2 года назад +6

    Great workshop!. Thanks Alejandra and Manuel 🥳

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      We're delighted that you've enjoyed the lesson, Yair. Thanks for the support!

  • @antoniopinho2071
    @antoniopinho2071 2 года назад +8

    Amazing presentation! What a star Ale! Thank you.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      Hi António! We couldn't agree more. Thanks for watching✨

  • @JahangirJadi
    @JahangirJadi 2 года назад +10

    Great workshop. Most of my concepts are cleared now. Thanks to both.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      Happy to hear the tutorial was helpful, Jahangir. You can also check out the following link to follow along with our Jetpack Compose codelab: goo.gle/3ssNnBO

  • @hmsmurtaza
    @hmsmurtaza Год назад +1

    val count: MutableState = mutableStateOf(0)
    Here, mutableStateOf(0) was showing error, that is why used direct
    val count = remeber { mutableStateOf(0) }
    then it worked correctly

  • @lsbrujah
    @lsbrujah 2 года назад +11

    Thanks for the presentation, amazing duo.

  • @fernandosproviero1663
    @fernandosproviero1663 2 года назад +5

    Great video! Congrats Alejandra and Manuel! Looking forward for more explanations like this :]

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      We're delighted to know you enjoyed this video from Alejandra and Manuel!
      We love hearing feedback from our community members 🙂
      If you liked this, don't forget to check out more Google I/O 2022 Sessions linked below → goo.gle/IO22_AllSessions

  • @dhananjaykulkarni6102
    @dhananjaykulkarni6102 2 года назад +1

    Yes I did code along. This video solved my big problem of not maintaining state of switch. Thanks a lot.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      We're happy to hear this, Dhananjay! If you'd like to learn more about Jetpack Compose, check the following codelab: goo.gle/3ssNnBO 😀

  • @KoradiyaAbhay
    @KoradiyaAbhay 2 года назад +4

    Very great content. Want to see about every concept of compose.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      Jetpack Compose is like a sponge. There are so many wonderful features that you can absorb just like water! Want to learn more? Check here: goo.gle/3rBdmWO 🧽

  • @maxiroson
    @maxiroson 2 года назад +5

    Nice video !!! Very clear explanation.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      We're happy to know this lesson from Alejandra and Manuel provided some helpful guidance. If you are interested in learning more check out these awesome guides: developer.android.com/jetpack/getting-started

  • @favour2871
    @favour2871 Год назад +1

    helped me a lot, was struggling with state for a bit

    • @AndroidDevelopers
      @AndroidDevelopers  Год назад +1

      Thanks for watching! We're so happy to hear it was helpful 😎

  • @trejkaz
    @trejkaz 10 месяцев назад

    My big state-related question: What about remembering state across invocations of the application? Is there a clean way to do that?
    My reasoning:
    1. `rememberSaveable` will persist the state across screen rotations
    2. The way `rememberSaveable` works is to persist the data to a bundle
    3. Persisting to a bundle should also work across application restarts - but the framework does not do this for us
    I know I could go all the way to using a full database which I store the state in... but this is more complex than you might initially think!
    For example, if I have a call to `mutableStateOf()` in a function which is called via two separate paths, Compose will correctly create two separate state vars, and I don't have to think about it.
    So if I wanted to store state in a database, I'd have to have some way to generate a sensible key for the state. But implementing that myself requires somehow knowing Compose internals, and I'm not even sure how to do that reliably. Also consider what happens if a new version of the application comes out, where the path to the state changes. :(
    _Ideally_, `rememberSaveable` would just do this for us without having to write anything else. But it doesn't, so what should we be doing?

  • @amirhosseinghafoorian9985
    @amirhosseinghafoorian9985 2 года назад

    It was an amazing workshop and nice presentation ale .

  • @pantelischas9460
    @pantelischas9460 2 года назад +2

    nice video, it is helpful to understand the state in compose

  • @harshpratapsingh1638
    @harshpratapsingh1638 2 года назад +1

    Really it helped a lot clear my doubts about state hoisting

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      Glad to hear you found the video helpful, Harsh 🙂
      You can also check out the following link to follow along with our Jetpack Compose codelab: goo.gle/3ssNnBO

  • @wilsonahanmisi1187
    @wilsonahanmisi1187 2 года назад +2

    Nice One Ale and Manuel

  • @nickryan4953
    @nickryan4953 4 месяца назад

    If you are attempting to explain state while dodging the question of View Models or related architecture, you have succeeded.

  • @apvasanth031
    @apvasanth031 2 года назад +1

    Thanks for the great workshop.

  • @schinsky6833
    @schinsky6833 2 года назад +1

    love the bright theme.

  • @holatechm
    @holatechm Год назад

    awesome,,,,,, you guys taught us like baby, which is must must-needed

  • @yasserakbbach7342
    @yasserakbbach7342 2 года назад +3

    Just wow, can we have a workshop about Dagger Hilt with multi-module project?

    • @manuelvicnt
      @manuelvicnt 2 года назад +1

      Thanks for the suggestion! We'll keep it in mind :) thanks!

    • @manuelvicnt
      @manuelvicnt 2 года назад +1

      Thanks for the suggestion! We'll keep it in mind :) thanks!

    • @Sherimankind
      @Sherimankind 2 года назад

      @@manuelvicnt make a tutorial on creating Menubar with jetpack compose those ones available on documentation are for XML

  • @TarekBuhdeima
    @TarekBuhdeima 2 года назад +2

    I wonder how Alejandra using these (step #) to past codes snippets so fast @30:14

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +2

      Great question and we're happy to share some insight!
      Live templates allow you to enter code snippets for fast insertion and completion of small chunks of code. They're great for saving time when you have a lot of repeating code you're needing to write ⏰
      You can learn more here: goo.gle/3MRH17L

  • @alfredlotsu9580
    @alfredlotsu9580 2 года назад +2

    Man you guys are geniuses

  • @AaronFleshner
    @AaronFleshner 11 месяцев назад

    This was awesome thank you for this video is was great!

  • @VoPoHo
    @VoPoHo 2 года назад +2

    Great content, thanks!

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      We have so many amazing resources for Jetpack Compose, and we can't wait to share them with you all! Check out our course here: goo.gle/compose-pathway
      All aboard the learning train 🚂

  • @BrunoMilhan
    @BrunoMilhan 2 года назад +1

    Thanks guys :)

  • @tilibip
    @tilibip 2 года назад +1

    Thanks guys!
    One question: which one should we use from these two?:
    - LiveData in the ViewModel with `val state by viewModel.liveData.observeAsState()` in the Composable?
    - or a MutableState like `var state by mutableStateOf(value)` directly in the ViewModel?

  • @oraofficial7899
    @oraofficial7899 Год назад

    well made video and good explanation video, thanks

  • @aseemsharma4643
    @aseemsharma4643 2 года назад +1

    Nice workshop! I am very eager to convert the existing codebase with composable functions, the only thing stopping is the backward compatibility, our app supports min SDK 16 and compose works from SDK 21 ☹

  • @alfredlotsu9580
    @alfredlotsu9580 2 года назад +2

    Thanks for this

  • @tomhockemeyer2370
    @tomhockemeyer2370 2 года назад +1

    So usefull lesson! Thanks!

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад +1

      Thank you so much for your feedback, Tom! We appreciate it! And of course you can also check out our State in Jetpack Compose Codelab for a more hands-on tutorial, here 😄 → goo.gle/3JVtzOP

  • @gonzalorenedo6834
    @gonzalorenedo6834 2 года назад

    niiice, saludos desde españa!

  • @ksenchy
    @ksenchy 2 года назад +3

    No Pancho this time? 🤣 Great video for people starting with compose

  • @someperson6343
    @someperson6343 2 года назад

    This is a great video, and much more informative and interesting than the code labs due to your recommendations, tips, key concepts etc. Also code labs are boring and you too are the opposite. Its fun to watch with a mega pint of coffee.

  • @DanielLuche
    @DanielLuche 2 месяца назад

    Great job

  • @SYBCA
    @SYBCA 4 месяца назад

    My screen is boosted 🎉

  • @user-not_defined
    @user-not_defined Год назад +1

    Oh my eyes, white theme in Android Studio😅

  • @shehramjamil966
    @shehramjamil966 2 года назад +1

    very informative.

    • @AndroidDevelopers
      @AndroidDevelopers  2 года назад

      We're so glad to hear that you enjoyed it, Shehram! Be sure to check out the links in the description for even more tips and tutorials 😎

  • @kirwakelvinkering3122
    @kirwakelvinkering3122 Год назад

    Lets assume we are building a bank managemnt system , a user logs in , and the login details should be made available to all the screens in the app, when a user sends the app yo the background , he/she is logged out due to the sensitivity of the app ,how can we acheive this ?

  • @moaliyou
    @moaliyou Год назад

    How about if we change the screen from portrait to landscape with some checked tasks and then try to check new tasks with landscape screen if we go back to portrait mode why we lose the checked tasks after screen rotation?
    N.B: I used the rememberSabeable lambda also.

  • @AK2000YY
    @AK2000YY 9 дней назад

    thank you.

  • @nayandhabarde
    @nayandhabarde 2 года назад +2

    Why should I not use rememberSaveable always instead of remember

    • @AlejandraStamato
      @AlejandraStamato 2 года назад +4

      This is a great question!
      You should use rememberSaveable if that's what your UX requires, as it creates a persistent source of truth, it really does depend on your usecase. There might be cases where you might not want to restore the screen to what it used to be. Also, creating Savers for some objects might not be trivial and it becomes a bit boilerplate-y.

  • @fernandogoncalves1891
    @fernandogoncalves1891 9 месяцев назад

    where can we find all the steps? Thanks

  • @johnhammer8668
    @johnhammer8668 Год назад

    How is state implemented internally. Are there any talks or docs ?

  • @leandroperalta
    @leandroperalta 2 года назад

    Che, la versión en español cuando sale? 😉

  • @user-not_defined
    @user-not_defined Год назад

    Couldn't you explain please. Why remember api doesn't working as rememberSaveable by default? Is it really so possible to score memory critically that it is necessary to separate? Maybe yes and good practice to separate api, a know it. But i'm interested)

  • @bolanoluwa6686
    @bolanoluwa6686 6 месяцев назад

    Thanks

  • @ellasaro
    @ellasaro Год назад

    Hi! The viewModel() documentation says that it: Returns an existing ViewModel or creates a new one in the given owner (usually, a fragment or an activity). So if my screens all live inside the same Activity would this mean that, after instantiating several screens, all those ViewModels are also instantiated and kept around while the Activity is still active? Is this efficient?

  • @flutterVerseMyanmar
    @flutterVerseMyanmar 3 месяца назад

    Super cool!!!! Excellent tutorial

  • @denisandreev2835
    @denisandreev2835 2 года назад +1

    Thanks! Nice tutorial! But what if checkbox state was part of your dataclass (as selected: Boolean)? I can't figure out how to handle this situation.

    • @hdokit9248
      @hdokit9248 2 года назад +2

      That is described in the last step of the Codelab,. Check it out: developer.android.com/codelabs/jetpack-compose-state#11

    • @denisandreev2835
      @denisandreev2835 2 года назад

      @@hdokit9248 Thanks! 👍

  • @aliisazadeh6973
    @aliisazadeh6973 2 года назад +2

    please code along the workshop not just copy and paste the code

  • @muhammadnizwa9104
    @muhammadnizwa9104 Год назад

    Hi, great video.
    I have a question for the codelab in migrating check state.
    Why we need to change data class to regular class? How about like this? Thanks!
    data class WellnessTask(val id: Int, val label: String, var initialChecked: Boolean = false) {
    var checked by mutableStateOf(initialChecked)
    }

  • @franktimestamp
    @franktimestamp 2 года назад

    Nice Vijeo

  • @517Amit
    @517Amit Год назад

    Have watched 🙂

  • @s4ril
    @s4ril 2 года назад

    looks like for `BacisStateCodelab` project end solution was merged to the main branch ;(

    • @AlejandraStamato
      @AlejandraStamato Год назад

      You start from a blank project and the code in main branch is the final/solution code.

  • @KangJangkrik
    @KangJangkrik 2 года назад

    I don't understand why assigning Modifier class as function parameter, it's not an object after all

    • @saidooubella
      @saidooubella 2 года назад +2

      It is. It is Modifier's companion object that implements the Modifier interface.

    • @KangJangkrik
      @KangJangkrik 2 года назад

      @@saidooubella I came from Java mindset, what I confused is why not use it directly from "import" keyword. Companion is equivalent as static in Java, right?

    • @saidooubella
      @saidooubella 2 года назад +1

      @@KangJangkrik Yes. In Kotlin-JVM companion objects are just inner static singleton classes.

  • @cularu1
    @cularu1 2 года назад +1

    flutter style stateful and stateless widgets?

    • @saidooubella
      @saidooubella 2 года назад +1

      Kind of, it's just up to you to make them either stateless or stateful. In Flutter it's forced through inheriting the StatelessWidget or StatefulWidget IMO.

  • @liaozhangpeng4436
    @liaozhangpeng4436 Год назад

    removing remember function to keep state would be more intuitive

  • @Shakenbeer
    @Shakenbeer 2 года назад

    Whata is the reason to have 'remember' at all?

    • @AlejandraStamato
      @AlejandraStamato 2 года назад +3

      For simpler state to be retained across recomposition, animation state is in general a good use case.

    • @Shakenbeer
      @Shakenbeer 2 года назад

      @@AlejandraStamato makes sense

  • @kirwakelvinkering3122
    @kirwakelvinkering3122 Год назад

    We are having a lot of problems syncronizing the dependencies ,can you help us come up with a way, just as in the spring boot initializer to create an app and include all dependecies without any conflicts ,thanks you so much .

  • @foxman6611
    @foxman6611 10 месяцев назад

    Greet

  • @lixoten344
    @lixoten344 Год назад +1

    Great Codelab but the code-along in this one left alot to be desired. the cut and paste is not a good idea for code-along

  • @ingenieroluisfer
    @ingenieroluisfer 11 месяцев назад

    👋🏼🇨🇴🧔🏻👍🏻🤝🏻

  • @deepmashru8951
    @deepmashru8951 2 года назад

    I am at wrong place😴😴😴

  • @hvaandres
    @hvaandres Год назад

    In the documentation it mention that we will need to add this to the build.gradle "implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1" but is not working. You will get the following error message "Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules kotlin-stdlib-1.8.10"

  • @god_bika
    @god_bika 2 месяца назад

    8:34 its not a religion to believe !
    add in Text() ", color= colorResource(getColorR()"
    and a function outside the scope:
    private fun getColorR():Int{
    val color:Int = Random.nextInt(4)
    var result_:Int=0
    when (color) {
    0 -> result_=R.color.teal_700
    1 -> result_=R.color.teal_200
    2 -> result_=R.color.purple_200
    3 -> result_=R.color.purple_500
    }
    return result_
    }
    And you gonna see how Text redraws itself by button click

  • @ashwithchandra2622
    @ashwithchandra2622 2 года назад

    What I have to do if i want to use the texfield value and want to change its state outside the function. I have done it by returning the String from the textfield that is initialized as the variable that stores the remember savable I have returned it but my app is crashing..🥲🥲