Hi everyone! I have a question about the Compose D...
# compose-desktop
m
Hi everyone! I have a question about the Compose Desktop development workflow and preview experience. I don't want to clutter the channel with a long message, so I've posted the details in this thread. Any suggestions would be greatly appreciated.
I'm working on a Compose Multiplatform JVM Desktop application and I'm trying to speed up UI development. To compare the behavior, I created two sample projects: • Project 1: Android + JVM • Project 2: JVM only On Android, Compose Preview is excellent. It has Interactive Mode, so I can click buttons, test animations, and iterate on the UI without launching the whole application. My production application, however, is JVM Desktop only. It performs a lot of calculations during startup, so every small UI change requires: • Running the entire application • Waiting for initialization and data loading • Navigating back to the screen I'm working on I also tried Compose Hot Reload, but it reloads the screen state, so the expensive initialization happens again. I noticed that Desktop Preview also requires me to manually click Refresh after code changes. Is there any way to make it refresh automatically like Android Preview? So I'm wondering: • Is there an Android-like Interactive Preview for Compose Desktop? • Can Desktop Preview automatically refresh after code changes? • How do you usually iterate on UI in large Compose Desktop applications without repeatedly launching the full app? Any recommended workflow or best practices would be very helpful. Thanks!
s
I also tried Compose Hot Reload, but it reloads the screen state, so the expensive initialization happens again.
This sounds like you're loading data in the composition, which is a big no-no for Compose architectures
☝️ 1
☝🏾 1
the tl;dr is that Hot Reload as of today is your best bet. Desktop previews are not nearly as good as Android ones, and there is no clear indication of when/if they'll catch up.
If you architect your code correctly, Hot Reload works, and is arguably a lot better for what you want to do than previews
💯 1
m
Thanks for the explanation! Sorry, I don't have much experience with Compose Hot Reload yet. I actually didn't realize it reloads automaticallyI accidentally pressed Cmd + S and was surprised that it refreshed. 😄 My main confusion was whether Compose Desktop has an Android-like Interactive Preview (where you can interact with the UI directly in the preview). From what I understand now, that isn't available yet, right? I was also wondering if Desktop Preview can automatically refresh after code changes. I'm not sure if that's expected behavior or if there's something I'm missing.
s
I don't think you are missing anything, the tooling for CMP is not nearly as advanced as the Android tooling. Much smaller team and much newer tooling tho, so that's to be expected
And Hot Reload is great 🙂
m
ui ignore it👀
in android studio Interactive Preview missing i guess? for compose desktop? may be it possible in future
Thanks, @seb!
K 1
Hot reload awesome i feel currentlyK
🔥 1
@seb I see your youtube channel many podcast video i watch ago. it great job
s
Thank you ❤️
K 1
m
is that any issue why always bin folder create in kmp