Тёмный

State in Jetpack Compose 

Android Developers
Подписаться 1,3 млн
Просмотров 73 тыс.
50% 1

Опубликовано:

 

3 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 112   
@ZachKlippenstein
@ZachKlippenstein 2 года назад
I like that Manuel’s intro was stateful 😂
@manuelvicnt
@manuelvicnt 2 года назад
🤣🤣🤣
@AndroidDevelopers
@AndroidDevelopers 2 года назад
It's really just the State of mind. 😎
@marlonlom
@marlonlom Год назад
🤣🤣🤣🤣
@인수백-e6e
@인수백-e6e Год назад
​@@AndroidDevelopers😢
@인수백-e6e
@인수백-e6e Год назад
​@@AndroidDevelopers😢
@jonathancampos8929
@jonathancampos8929 2 года назад
Wow! Thanks for this presentation, the speakers did an incredible job together. Excited to watch new content with you two folks
@AndroidDevelopers
@AndroidDevelopers 2 года назад
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☺️
@chtiboss78
@chtiboss78 2 года назад
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 года назад
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
@isabelporto5243
@isabelporto5243 2 года назад
Ale you are the best! Thank you so much for the presentation.
@anaibrahim4361
@anaibrahim4361 Год назад
I truly didn't know how to thank you for giving this to us for free.
@anibalbastiass
@anibalbastiass 2 года назад
Great workshop! I really like the clear explanation and solved my doubts about the Composable States. You rock guys!
@AndroidDevelopers
@AndroidDevelopers 2 года назад
Thanks for the wonderful feedback; we're glad it was helpful! 😁
@JahangirJadi
@JahangirJadi 2 года назад
Great workshop. Most of my concepts are cleared now. Thanks to both.
@AndroidDevelopers
@AndroidDevelopers 2 года назад
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
@antoniopinho2071
@antoniopinho2071 2 года назад
Amazing presentation! What a star Ale! Thank you.
@AndroidDevelopers
@AndroidDevelopers 2 года назад
Hi António! We couldn't agree more. Thanks for watching✨
@YairCarreno
@YairCarreno 2 года назад
Great workshop!. Thanks Alejandra and Manuel 🥳
@AndroidDevelopers
@AndroidDevelopers 2 года назад
We're delighted that you've enjoyed the lesson, Yair. Thanks for the support!
@lsbrujah
@lsbrujah 2 года назад
Thanks for the presentation, amazing duo.
@dhananjaykulkarni6102
@dhananjaykulkarni6102 2 года назад
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 😀
@favour2871
@favour2871 Год назад
helped me a lot, was struggling with state for a bit
@AndroidDevelopers
@AndroidDevelopers Год назад
Thanks for watching! We're so happy to hear it was helpful 😎
@ChicoRasia_CLabs
@ChicoRasia_CLabs Год назад
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!
@fernandosproviero1663
@fernandosproviero1663 2 года назад
Great video! Congrats Alejandra and Manuel! Looking forward for more explanations like this :]
@AndroidDevelopers
@AndroidDevelopers Год назад
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
@maxiroson
@maxiroson 2 года назад
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
@harshpratapsingh1638
@harshpratapsingh1638 2 года назад
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
@MuhammadWaheed-r4l
@MuhammadWaheed-r4l 7 месяцев назад
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.
@schinsky6833
@schinsky6833 2 года назад
love the bright theme.
@KoradiyaAbhay
@KoradiyaAbhay 2 года назад
Very great content. Want to see about every concept of compose.
@AndroidDevelopers
@AndroidDevelopers 2 года назад
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 🧽
@pantelischas9460
@pantelischas9460 2 года назад
nice video, it is helpful to understand the state in compose
@holatechm
@holatechm Год назад
awesome,,,,,, you guys taught us like baby, which is must must-needed
@apvasanth031
@apvasanth031 2 года назад
Thanks for the great workshop.
@wilsonahanmisi1187
@wilsonahanmisi1187 2 года назад
Nice One Ale and Manuel
@trejkaz
@trejkaz 9 месяцев назад
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?
@AaronFleshner
@AaronFleshner 9 месяцев назад
This was awesome thank you for this video is was great!
@amirhosseinghafoorian9985
@amirhosseinghafoorian9985 2 года назад
It was an amazing workshop and nice presentation ale .
@TarekBuhdeima
@TarekBuhdeima Год назад
I wonder how Alejandra using these (step #) to past codes snippets so fast @30:14
@AndroidDevelopers
@AndroidDevelopers Год назад
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 года назад
Man you guys are geniuses
@VoPoHo
@VoPoHo 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 🚂
@seksky333
@seksky333 2 года назад
I found what Manual said at the end about only passing the view model on screen-level composable not other composable functions was really useful.
@AndroidDevelopers
@AndroidDevelopers 2 года назад
Thanks for your feedback, Ches! Don't forget you can view the codelab for Using state in Jetpack Compose here: goo.gle/3ssNnBO
@seksky333
@seksky333 2 года назад
@@AndroidDevelopers Yah, I've already completed the codelab and am using it as my reference for my new Android role in an eCommerce business. Looking forward to see more great features from Compose.
@DanielLuche
@DanielLuche 15 дней назад
Great job
@alfredlotsu9580
@alfredlotsu9580 2 года назад
Thanks for this
@BrunoMilhan
@BrunoMilhan 2 года назад
Thanks guys :)
@oraofficial7899
@oraofficial7899 Год назад
well made video and good explanation video, thanks
@hmsmurtaza
@hmsmurtaza Год назад
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
@tomhockemeyer2370
@tomhockemeyer2370 2 года назад
So usefull lesson! Thanks!
@AndroidDevelopers
@AndroidDevelopers 2 года назад
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 Год назад
niiice, saludos desde españa!
@tilibip
@tilibip Год назад
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?
@yasserakbbach7342
@yasserakbbach7342 2 года назад
Just wow, can we have a workshop about Dagger Hilt with multi-module project?
@manuelvicnt
@manuelvicnt 2 года назад
Thanks for the suggestion! We'll keep it in mind :) thanks!
@manuelvicnt
@manuelvicnt 2 года назад
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
@SYBCA
@SYBCA 2 месяца назад
My screen is boosted 🎉
@aseemsharma4643
@aseemsharma4643 2 года назад
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 ☹
@bolanoluwa6686
@bolanoluwa6686 4 месяца назад
Thanks
@shehramjamil966
@shehramjamil966 2 года назад
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 😎
@aliisazadeh6973
@aliisazadeh6973 2 года назад
please code along the workshop not just copy and paste the code
@nickryan4953
@nickryan4953 2 месяца назад
If you are attempting to explain state while dodging the question of View Models or related architecture, you have succeeded.
@flutterVerseMyanmar
@flutterVerseMyanmar 2 месяца назад
Super cool!!!! Excellent tutorial
@nayandhabarde
@nayandhabarde 2 года назад
Why should I not use rememberSaveable always instead of remember
@AlejandraStamato
@AlejandraStamato 2 года назад
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.
@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 ?
@johnhammer8668
@johnhammer8668 Год назад
How is state implemented internally. Are there any talks or docs ?
@moaliyou
@moaliyou 11 месяцев назад
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.
@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)
@franktimestamp
@franktimestamp 2 года назад
Nice Vijeo
@ksenchy
@ksenchy 2 года назад
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.
@517Amit
@517Amit Год назад
Have watched 🙂
@fernandogoncalves1891
@fernandogoncalves1891 7 месяцев назад
where can we find all the steps? Thanks
@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) }
@leandroperalta
@leandroperalta 2 года назад
Che, la versión en español cuando sale? 😉
@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?
@denisandreev2835
@denisandreev2835 2 года назад
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 года назад
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! 👍
@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.
@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 .
@KangJangkrik
@KangJangkrik 2 года назад
I don't understand why assigning Modifier class as function parameter, it's not an object after all
@saidooubella
@saidooubella 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 года назад
@@KangJangkrik Yes. In Kotlin-JVM companion objects are just inner static singleton classes.
@cularu1
@cularu1 2 года назад
flutter style stateful and stateless widgets?
@saidooubella
@saidooubella 2 года назад
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.
@user-not_defined
@user-not_defined Год назад
Oh my eyes, white theme in Android Studio😅
@Shakesbeer1
@Shakesbeer1 2 года назад
Whata is the reason to have 'remember' at all?
@AlejandraStamato
@AlejandraStamato 2 года назад
For simpler state to be retained across recomposition, animation state is in general a good use case.
@Shakesbeer1
@Shakesbeer1 2 года назад
@@AlejandraStamato makes sense
@foxman6611
@foxman6611 8 месяцев назад
Greet
@liaozhangpeng4436
@liaozhangpeng4436 Год назад
removing remember function to keep state would be more intuitive
@lixoten344
@lixoten344 Год назад
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 9 месяцев назад
👋🏼🇨🇴🧔🏻👍🏻🤝🏻
@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 Месяц назад
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..🥲🥲
Далее
Performance best practices for Jetpack Compose
21:17
Просмотров 85 тыс.
Advanced state and side effects in Jetpack Compose
41:21
Women’s Celebrations + Men’s 😮‍💨
00:20
Просмотров 2,8 млн
КОТЯТА НАУЧИЛИСЬ ГОВОРИТЬ#cat
00:13
Understanding Compose (Android Dev Summit '19)
36:15
Просмотров 72 тыс.
Lazy layouts in Compose
24:32
Просмотров 93 тыс.
Basic layouts in Compose
1:01:41
Просмотров 62 тыс.
State holders and state production in the UI Layer
20:53
Full Guide to Jetpack Compose Effect Handlers
24:56
Просмотров 94 тыс.
Practical magic with animations in Jetpack Compose
32:46
More performance tips for Jetpack Compose
20:47
Просмотров 40 тыс.
Thinking in Compose
25:27
Просмотров 87 тыс.
Women’s Celebrations + Men’s 😮‍💨
00:20
Просмотров 2,8 млн