derivedStateOf VS. remember(key) - THIS is Really the Difference 🤯

  Рет қаралды 19,359

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 52
@stanleykou5643
@stanleykou5643 11 ай бұрын
Your "20 things you should never do in Jetpack Compose" PDF was super useful. Jetpack compose is full of traps, and your tip is like a mine detector!
@ErnestoVega
@ErnestoVega 11 ай бұрын
How did you get it, please? I already got subscribed to the newsletter but I can't find nor get it anywhere.
@lr56c60
@lr56c60 11 ай бұрын
Could you temporarily upload it to a cloud? I haven't been able to click the button for several weeks. I have tried different internet providers and devices. Thanks
@pelealexandru
@pelealexandru 11 ай бұрын
I want it as well. Where do we get it?
@lr56c60
@lr56c60 11 ай бұрын
@@pelealexandru did you try phillip's page? I am asking here because the button to obtain the pdf on his page does not work for me.
@pelealexandru
@pelealexandru 11 ай бұрын
yes just tried it 10 minutes ago but didn't get the pdf @@lr56c60
@Alchemist10241
@Alchemist10241 11 ай бұрын
7:41 the best explanation I've ever heard or read that clarifies the use case of these two function, well done Philipp 👍
@AdrianTache
@AdrianTache 11 ай бұрын
Compose always feels like such an unfinished project... I'd expect `remember` to handle all these kinds of edge cases under the hood and prevent recompositions as needed, rather than requiring all these clumsy hacks to either prevent or force recompositions, depending on the situation. Having said that, thanks for the video, it's a nice summary of these issues and how to solve them!
@ChrisAthanas
@ChrisAthanas 11 ай бұрын
The documentation is improving slowly and compose is definitely an improvement over the xml madness
@AdrianTache
@AdrianTache 9 ай бұрын
@@ChrisAthanas not sure I entirely agree, Compose just hides away a lot of what is still happening to views, turning annoying issues into hidden annoying issues. I'm still a fan, primarily because we're finally getting rid of states inside views (with some horrific exceptions, like how that stupid text selection can STILL crash your app because it get stuck in the wrong state sometimes), but it's probably going to be years until it's actually at a comparable level of stability with xml.
@زيد_اليماني
@زيد_اليماني 11 ай бұрын
I always watch your videos because they are very helpful and moreover you break things down in a clear and easy way, your pdf is amazing
@callebdev
@callebdev 11 ай бұрын
Thanks a lot Philipp. I was also struggling to understand the difference between both of them. Your explanation was literally amazing! 💯
@mahiainti678
@mahiainti678 11 ай бұрын
at 12:03 if my understanding is correct you can alternatively explicitly pass isEnabledState as a state into derivedStateOf and not set keys in remember. In this way derivedStateOf would monitor both of the states inside of it. I.e. `derivedStateOf { state.firstVisibleItemIndex >= 5 && isEnabledState.value }`
@muhmmedalsadig7706
@muhmmedalsadig7706 11 ай бұрын
I agree 👍
@osisuper98
@osisuper98 11 ай бұрын
If you are going to pass state as a parameter, how are you supposed to change its value ?
@mahiainti678
@mahiainti678 11 ай бұрын
@@osisuper98 just the usual way? state.value = newValue somewhere else
@jackeblan
@jackeblan 11 ай бұрын
It's better to put the isEnabled to if(showScrollToTopButton && isEnable)
@音羽の夢
@音羽の夢 9 ай бұрын
@@osisuper98 add another onValueChange callback
@SalahHoumdi
@SalahHoumdi 11 ай бұрын
Without bias, if you were to choose between compose or views, which one would you use in your project? For a better performance.
@Maham-g9d
@Maham-g9d 5 ай бұрын
i have read answer on stackoverFlow but not got it , you explain it very well in 14 min thanks
@alexeysimchenko7494
@alexeysimchenko7494 11 ай бұрын
I knew that case but always is good to repeat) And I found out from this video that derivedStateOf is not updated if argument is updated and I need to pass such agrument as a key to remember. Thanks for mentioning that
@LasradoRohan
@LasradoRohan 11 ай бұрын
You are reading my mind at this point
@PhilippLackner
@PhilippLackner 11 ай бұрын
You're welcome
@stewie2k519
@stewie2k519 11 ай бұрын
Hey, I've watched your video about Content Providers. I am currently working with one of them - Calendar Provider, developing a small calendar-app. Do you have any other videos on this topic or maybee you can reccomend some other sources where I can read/watch about this specific provider? Espicially about syncing calendars from local storage to a server and vice-versa. And another thing is - is there some library that provides a CalendarView like Google Calendar have (the monthly view grid with displayiing event's preview(titles) in each cell)? Thanks😅
@vomeg
@vomeg Ай бұрын
11:55 -- it's a bad advice to use "key" with "remember(key) {derivedStateOf {...} }" because it will produce a different instance of State every time key changes - which will mess up downstream `derivedStateOf` usages of this state. The downstream `derivedStateOf`s will bind to an "old" instance of the `State` and won't re-calculate when needed, causing bugs. In this video, this works only because the State is used as a primitive Boolean.
@zeredantech2966
@zeredantech2966 6 ай бұрын
Also i want to admit that remember with keys can be used in all cases, but when used with provided state(state in ViewModel or like in this video, provided by fun argument) it calls implicit get() on state, which adds it to the recomposition list, and if you are not going to subscribe to this state it will be more effective to use derivedStateOf(), because it adds only evaluation function to this list. But if you already have subscribed to the state there will be better to add state.value to remember key list, because it will anyway recompose and if not doing this, you can get a double-recomposition, i mean when state changes and we use derivedStateOf() it firstly recomposes our function, after this it recomposes evaluation, it changes too and here it is second recomposition of function due to change of derived state. But when you are having a provided argument value, which can change(not a state), the derivedStateof() couldn't subscribe to this and you will have to use remember with keys. Also all this is safe in state group cases, i mean that if you are having k states for evaluation and n states (n > k) for compose fun, when some of "useless" states changes it will not cause reevaluations, because in both cases(derivedStateof(), remember(keys)) we refresh only if our "usefull" k states updates
@mortezamgh1347
@mortezamgh1347 7 ай бұрын
Thanks dear Philipp, very useful tutorial 👍
@chorvico
@chorvico 11 ай бұрын
Awesome explanation! Thanks for sharing this!
@AdevAxmeddev
@AdevAxmeddev 11 ай бұрын
Thanks a lot Philipp Lackner. It is amazing...!
@mbpiku
@mbpiku 11 ай бұрын
This was really insightful, thanks 🙏
@ubersticks
@ubersticks 11 ай бұрын
How do I get the PDF? I am already a subscriber and the link seems to be only for new subscribers.
@amol1608
@amol1608 11 ай бұрын
hey Philipp, the subscription for the free PDF is not working. I tried with one mail, never got a link. I tried with another mail (that was never subscribed), got a link, but the link from the email doesn't work, I get a 404.
@SSG1239
@SSG1239 11 ай бұрын
Hey Philipp, can you please make a video regarding content driven concepts & if possible some mini projects that will be a great help.
@purplehazer417
@purplehazer417 11 ай бұрын
Phillip, can you explain the difference between rememberUpdatedState(key) and remember(key) { mutableStateOf(key) }
@GillellaAvinashreddy
@GillellaAvinashreddy 11 ай бұрын
Sir i am learning jetpack compose to become android developer .Do i need to learn DSA to become android developer. Because at college placements we required DSA is it necessary
@RubySeo-s5c
@RubySeo-s5c 5 ай бұрын
I've subscribed to your email List but can't download "20 things you should never do in Jetpack Compose" PDF
@-ECE-SOGATAKAR
@-ECE-SOGATAKAR 11 ай бұрын
Thanks you are doing great job ❤
@mark-147
@mark-147 11 ай бұрын
How about if you put the >=5 inside the remember arg?
@fliamachado
@fliamachado 11 ай бұрын
Same question! I've that a loot, where the key is a boolean condition.
@henrik908
@henrik908 11 ай бұрын
No doubt why he is the king of Jetpack compose.
@utkubilgin2818
@utkubilgin2818 11 ай бұрын
Hi, I couldn't download the PDF
@tarsilacostalonga
@tarsilacostalonga 11 ай бұрын
You are the best!!
@pelealexandru
@pelealexandru 11 ай бұрын
Thanks!
@mustafaammar551
@mustafaammar551 11 ай бұрын
Thank you BRO
@neerajverma9226
@neerajverma9226 11 ай бұрын
Can you explain out and in generics here? RequestState {}
@WakeupDev.
@WakeupDev. 8 ай бұрын
Vivid and helpful
@varunagrawal5802
@varunagrawal5802 11 ай бұрын
U saved, thanks
@raulprior9635
@raulprior9635 11 ай бұрын
Amazing
@Revakovskyi
@Revakovskyi 11 ай бұрын
Thanks so much! You're the best!
@vitdemidenko
@vitdemidenko 11 ай бұрын
val state by)))))))
@5erTurbo
@5erTurbo 11 ай бұрын
4:30 I guess you could still do following and it would work same as using `derivedStateOf`? `remember(state.firstVisibleItemIndex >= 5)`
لماذا ينجح البعض ويفشل الآخرون؟ | صلاح أبوالمجد | 149
1:25:09
بودكاست بدون ورق
Рет қаралды 1,3 МЛН
Everything You Need to Know about derivedStateOf()
5:57
Stevdza-San
Рет қаралды 5 М.
Маусымашар-2023 / Гала-концерт / АТУ қоштасу
1:27:35
Jaidarman OFFICIAL / JCI
Рет қаралды 390 М.
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
The Top 3 State Management Mistakes On Android
14:30
Philipp Lackner
Рет қаралды 27 М.
Performance Optimization with @Stable and @Immutable in Jetpack Compose
16:47
3 Clean Code Hacks I Bet You Didn't Know (Kotlin & Android)
12:30
Philipp Lackner
Рет қаралды 29 М.
I built a React Native bottom sheet...with SwiftUI??
8:27
Fernando Rojo
Рет қаралды 946
The Essence of Coroutines
8:10
Dave Leeds
Рет қаралды 14 М.
DeepSeek is a Game Changer for AI - Computerphile
19:58
Computerphile
Рет қаралды 1,2 МЛН
This Is My FAVORITE Error Handling Class
28:57
Philipp Lackner
Рет қаралды 37 М.
Sealed Classes for UI State are an ANTI-PATTERN - Here's why!
9:53
Philipp Lackner
Рет қаралды 25 М.
remember, by, and mutableStateOf explained
10:07
Brandan Jones
Рет қаралды 4,4 М.
Grafana is the goat... Let's deploy the LGTM stack
5:59
Fireship
Рет қаралды 494 М.
Маусымашар-2023 / Гала-концерт / АТУ қоштасу
1:27:35
Jaidarman OFFICIAL / JCI
Рет қаралды 390 М.