Don't Do THIS Jetpack Compose Mistake

preview_player
Показать описание
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:

💻 Let me be your mentor and become an industry-ready Android developer in 10 weeks:

🎓 Become an industry-ready developer in the Mobile Dev Campus:

🎁 Get my FREE 4.5h course "The Best Practice Guide to Android Architecture":

Read our weekly Android blog:

Join this channel to get access to perks:

Join my Discord server:

You like my free content? Here you can buy me a coffee:
Рекомендации по теме
Комментарии
Автор

Because I've read this in many comments now:
Of course, putting this as state in the ViewModel works, too (and for filtering I'd honestly also do this myself).
But, that doesn't change the fact that doing this is a mistake (I'm often doing code reviews and saw this one very often). Also, there are scenarios where you can't simply put this in the viewmodel, e.g. If you need the context when mapping something to string resources for example.

PhilippLackner
Автор

I prefer another approach in this case.
I prefer preparing those 2 lists in the VM and move logic to there

yossimaskin
Автор

Also we can call partition on our list and get both done and undone items list

haykmkrtchyan
Автор

This one of the helpful things i need to do to optimize the apps I build, thanks!

meidy
Автор

Nice vid philipp, I hope you make some shorts about optimizing re-comipistions with "donut scoping", it revolves around the idea of inlining functions

maximooze
Автор

I'd just have an unmutable list/map of boolean states in the ViewModel that can be accessed/modified via public methods. That way there's no filtering of any sort and only the item(s) that changed will recompose.

st
Автор

It was really helpful, thanks for sharing

CodeWithNiks
Автор

I would be very happy if your courses could be priced by Region.... In Brazil, 99 euros are equal to half a month of paid work... and been unemployed is tricky

wagnerarcieri
Автор

Hi Phillip, how can i set toolbar color like bootom bar and status bar color like toolbar color ?

JustAmalll
Автор

I made every mistake you said don't do it 😂😂😂. Thanks Philipp

mesutemrecelenk
Автор

Thank you so much. Wish I had known this early

kyleMcBurnett
Автор

Thank you for sharing this information, it´s very helpful.
I think you could take the opportunity to say that this kind of logic shouldn't be in your UI framework.

carbaj
Автор

this was exactly what I needed without this I had to recompose a lazy vertical grid in an if else block

Alchemist
Автор

Can you pls create a video about libraries android provides and some history about different android version changes as it is difficult for a new developers to know what is new and what is not. Thank you

Joe-qvjo
Автор

Hey, Philipp.
Can you do a video for Rich text editor like most note application, please?

Walker
Автор

after applying this my UI loaded more smoothly, cool.

fars
Автор

Please always give the source code link!

ChrisAthanas
Автор

no logic other than a simple if in the ui. let vm drive the state.

tashi
Автор

Say I have a screen with 6 textboxes that the user can enter info into. Normally I'd see this represented as far as saving state by having 6 different state variables, one for each textbox (or really, two variables for each textbox, a private one in the ViewModel and a public one in the ViewModel, that the Composeable can access).

Couldn't I also make a single class, like "MyState", that has 6 fields in it, and then manage my screen's state by just referring to that single state variable that my ViewModel now contains?

So for example I'd just be referencing MyState.myVarOne, MyState.myVarTwo, ..., MyState.myVarSix rather than myVarOne, myVarTwo, ..., myVarSix. Hopefully that makes sense.

clamum
Автор

Really enjoy your videos! I've been doing Android apps as a hobby for a year or so now and your videos have been a great help!
Personally, i come from a web-development job so i'm by no means and Android expert. I'm wondering though, stuff like filtering the todos list and generally preparing data for the presentation layer, shouldn't that logic be done in the viewmodel or elsewhere? In my opinion and experience, the UI-layer shouldn't really do any other logic than implementing the UI, and the preparation of data shouldn't be the job of the UI-layer. Again, i'm by no means an app-developer so i'm sure i havent got the best understanding of good app architecture. Would appreciate your thougts on this!

jepp