Nacho Ruiz Martin
12/08/2023, 6:10 PMArkadii Ivanov
12/08/2023, 6:24 PMNacho Ruiz Martin
12/08/2023, 7:33 PMIām not sure if a Kotlin project is supposed to be consumed from JS.Thatās a pity š. I thought this sentence in the docs was trying to express that this is something prepared (screenshot). But I guess thatās referring to Kotlin/JS React, right? Also, I had some hope because of this: https://kotlinlang.org/docs/js-modules.html
But you can write React UI in Kotlin and use Decompose:Yes, I can try to convince them to switch to Kotlin but I think itāll be harder š .
Arkadii Ivanov
12/08/2023, 8:00 PMArkadii Ivanov
12/08/2023, 8:00 PMNacho Ruiz Martin
12/08/2023, 8:00 PMNacho Ruiz Martin
12/08/2023, 8:01 PMArkadii Ivanov
12/08/2023, 8:06 PMIs Kotlin/Wasm on the scope?
Yes, I'm trying to add support for WASM in the next Decompose 3.0.0-alpha01
Nacho Ruiz Martin
12/08/2023, 8:41 PMNacho Ruiz Martin
12/09/2023, 9:24 AMNacho Ruiz Martin
12/09/2023, 9:25 AMValue
, basically nothing can be exported. sealed class
, for example.Arkadii Ivanov
12/09/2023, 9:56 AMNacho Ruiz Martin
12/09/2023, 10:01 AMNacho Ruiz Martin
12/09/2023, 5:44 PM@JsExport
, the compiler is not available to type those properties and are exported as `any`:
//Typescript
export declare interface RootBloc /* extends Bloc<RootContract.State, RootContract.Event> */ {
readonly childStack: any/* Value<ChildStack<UnknownType *, RootBlocChild>> */; <-- LOOK AT THIS ANY
onDeepLink(link: string): void;
readonly __doNotUseOrImplementIt: {
readonly "app.spoiless.shared.root.RootBloc": unique symbol;
};
}
export declare function initRoot(appVersionName: string, appEnvironment: string): void;
This is kind of usable but certainly cumbersome. Do you think we could do something to Decompose to address this issue and if it would be worth it?Arkadii Ivanov
12/09/2023, 6:03 PMArkadii Ivanov
12/09/2023, 6:05 PMArkadii Ivanov
12/09/2023, 6:05 PMNacho Ruiz Martin
12/09/2023, 6:06 PMNacho Ruiz Martin
12/09/2023, 6:07 PMI have never seen any library annotated with JsExport.Yep, basically nothing is marked with JsExport. I guess Kotlin/JS was never though to be used from JS?
Arkadii Ivanov
12/09/2023, 6:10 PMI guess Kotlin/JS was never though to be used from JS?Correct. And it feels like going against the wind š I will try playing with it though.
Arkadii Ivanov
12/09/2023, 6:10 PMNacho Ruiz Martin
12/09/2023, 6:11 PMArkadii Ivanov
12/09/2023, 6:12 PMNacho Ruiz Martin
12/09/2023, 6:12 PMNacho Ruiz Martin
12/09/2023, 6:12 PMNacho Ruiz Martin
12/09/2023, 6:14 PMI will try playing with it though.Donāt feel the pressure. Iām giving up this approach. Iāll go down the āHey, please, learn to write your code in React for Kotlin, itās not that differentā path.
Arkadii Ivanov
12/09/2023, 6:26 PMIāll go down the āHey, please, learn to write your code in React for Kotlin, itās not that differentā pathIndeed! š
Arkadii Ivanov
12/09/2023, 6:53 PMArkadii Ivanov
12/09/2023, 7:10 PMArkadii Ivanov
12/09/2023, 7:10 PMArkadii Ivanov
12/09/2023, 7:10 PMNacho Ruiz Martin
12/09/2023, 9:51 PMArkadii Ivanov
12/27/2023, 10:15 AMNacho Ruiz Martin
12/27/2023, 10:58 AMArkadii Ivanov
12/27/2023, 11:21 AMArkadii Ivanov
12/27/2023, 11:23 AMArkadii Ivanov
12/27/2023, 11:24 AMArkadii Ivanov
12/27/2023, 11:26 AMNacho Ruiz Martin
12/27/2023, 1:06 PMNacho Ruiz Martin
12/27/2023, 3:56 PMArkadii Ivanov
12/27/2023, 4:59 PMNacho Ruiz Martin
12/27/2023, 5:17 PMNacho Ruiz Martin
01/08/2024, 2:13 PMArkadii Ivanov
01/08/2024, 2:27 PMArkadii Ivanov
01/08/2024, 2:29 PMNacho Ruiz Martin
01/08/2024, 2:37 PMArkadii Ivanov
01/08/2024, 2:39 PMArkadii Ivanov
01/08/2024, 3:01 PMNacho Ruiz Martin
01/08/2024, 3:02 PMArkadii Ivanov
01/08/2024, 9:10 PMNacho Ruiz Martin
01/09/2024, 12:58 PMArkadii Ivanov
01/09/2024, 1:03 PMNacho Ruiz Martin
01/09/2024, 1:03 PMNacho Ruiz Martin
01/09/2024, 1:48 PMArkadii Ivanov
01/09/2024, 1:55 PMNacho Ruiz Martin
01/09/2024, 1:57 PMNacho Ruiz Martin
01/09/2024, 2:01 PMArkadii Ivanov
01/09/2024, 2:14 PMNacho Ruiz Martin
01/09/2024, 3:09 PMArkadii Ivanov
01/09/2024, 3:10 PMNacho Ruiz Martin
01/09/2024, 3:24 PMNacho Ruiz Martin
01/09/2024, 3:24 PMNacho Ruiz Martin
01/09/2024, 3:26 PMNacho Ruiz Martin
01/09/2024, 3:27 PMArkadii Ivanov
01/09/2024, 3:27 PMArkadii Ivanov
01/09/2024, 10:04 PM:app:sBrowserDistribution
without exporting anything, the size of the resulting app.js
file is 2,067 bytes.
After running :app:sBrowserDistribution
with the class exported, the size of the resulting app.js
file is 2,197 bytes.
Am I doing something wrong?Nacho Ruiz Martin
01/10/2024, 7:43 AMArkadii Ivanov
01/10/2024, 10:06 PMjsBrowserDevelopmentExecutableDistribution
produces app.js
file of size 824Kb without exporting, and 826Kb with one class exported from the shared module.Arkadii Ivanov
01/10/2024, 10:09 PMArkadii Ivanov
01/10/2024, 10:36 PMDefaultRootComponent
class.
@JsExport
fun rootComponent(): RootComponent {
val lifecycle = LifecycleRegistry()
val root = DefaultRootComponent(componentContext = DefaultComponentContext(lifecycle = lifecycle))
lifecycle.attachToDocument()
return root
}
private fun LifecycleRegistry.attachToDocument() {
fun onVisibilityChanged() {
if (document.visibilityState == DocumentVisibilityState.visible) {
resume()
} else {
stop()
}
}
onVisibilityChanged()
document.addEventListener(type = EventType("visibilitychange"), callback = { onVisibilityChanged() })
}
Arkadii Ivanov
01/10/2024, 11:19 PMChildStack
contains List
properties, which cannot be exported. We would need to add separate array properties like backStackArray
and itemsArray
.Arkadii Ivanov
01/10/2024, 11:27 PMNacho Ruiz Martin
01/11/2024, 1:45 PMyou can expose a function creating the root component from your library?Yes, this can be a way, for sure. It would be cool to allow JS users to control the lifecycle of a component on their behalf, though. But this is only useful in some edge cases, I guess.
Also,Yes, indeed, I had to wrap things into a native array in the wrappers Iām using.containsChildStack
List
Nacho Ruiz Martin
01/11/2024, 1:49 PMArkadii Ivanov
01/11/2024, 1:53 PMArkadii Ivanov
01/11/2024, 1:53 PMNacho Ruiz Martin
01/11/2024, 1:57 PMSo the main question now is how it affects the size for all-in-Kotlin cases.Iāll create a basic project with and without these changes and let you know.
Arkadii Ivanov
01/12/2024, 1:00 PMNacho Ruiz Martin
01/12/2024, 2:11 PMArkadii Ivanov
01/24/2024, 1:24 PMNacho Ruiz Martin
01/24/2024, 1:26 PMArkadii Ivanov
07/27/2024, 10:48 PMNacho Ruiz Martin
07/29/2024, 11:56 AMArkadii Ivanov
07/29/2024, 4:49 PM