https://kotlinlang.org logo
#kobweb
Title
# kobweb
n

Nestor Ledon

04/01/2024, 2:14 PM
Hey everybody! Went down the compose rabbit hole yesterday and came across Kobweb. I've worked with KMP before for iOS/Android but new to compose. For my new project I want to start with a PWA and pull that in with a shared webview, ideally want to share business logic across mobile/web as well. Anyone kick something like this around yet?
c

CLOVIS

04/02/2024, 8:37 AM
If you're going to make Android and iOS apps, why go PWA instead of going native? To share domain code between KJS and the other platforms, you can simply create a multiplatform library module and depend on it from each platform. To share UI code, I'm working on #decouple but it's at least 2 or 3 years from being usable… To share data, you may be interested in https://github.com/cashapp/zipline.
But indeed, you can go full PWA with Kobweb only. I'm not sure how much tooling exists at the moment for this use case, Kobweb is still young so efforts mostly go towards making websites at the moment. It probably does work without major issues though.
d

David Herman

04/02/2024, 5:38 PM
I just looked up the steps for creating a PWA (which is a usecase I'd definitely like to support someday). Looks like everything is there except service worker support -- although it would be possible to create that without Kobweb. Note that Kobweb does support web workers, so it's possible either service workers can work using it as is or maybe the code requires a small tweak. I'll add an issue to take a look but it's not going to be a priority for a bit.
Here's a document I kept when researching workers in Kotlin/JS . There's some links in there to articles about how to create a worker manually.
I'd also be curious how you respond to Ivan's question!
n

Nestor Ledon

04/02/2024, 7:21 PM
@CLOVIS need to start with web support from the jump for the use case and iteratively introduce mobile where needed as needed. I'm not looking to share the UI at the moment but instead just pull the PWA into a webview initially.
d

David Herman

04/02/2024, 7:27 PM
One thing to note about workers in Kotlin JS is each worker needs its own (dead code eliminated) version of the runtime. I talk about it here at the end of this section: <https://github.com/varabyte/kobweb?tab=readme-ov-file#when-to-use-kobweb-workers>
👍 1
n

Nestor Ledon

04/02/2024, 7:29 PM
@David Herman I think I'd be okay with creating the worker outside of Kobweb. Just trying to understand what the initial lift is going to be here and if it makes sense. Maybe it's best to just run with Ktor if I'm not looking to share elements across web beyond the PWA.
d

David Herman

04/02/2024, 7:55 PM
In that case, you can look into creating a worker js file and put it in your resources/public folder. Good luck!
n

Nestor Ledon

04/02/2024, 11:54 PM
The more I chew on this the more I want to try this out Kobweb. I think I'm going to give it a soft touch and see where I get.
👍 1
d

David Herman

04/02/2024, 11:55 PM
I hope you enjoy the test run! Sometimes I don't get slack notifications but I try to be around every day if people have questions.
5 Views