Skip to content

add onWasmReady #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add onWasmReady #445

wants to merge 2 commits into from

Conversation

ElviraMustafina
Copy link
Collaborator

No description provided.

@ElviraMustafina ElviraMustafina requested a review from eymar June 20, 2025 01:41
@ElviraMustafina ElviraMustafina requested a review from a team as a code owner June 20, 2025 01:41
val name = initRoute.substringAfter("patient_").substringBefore("_")
val id = initRoute.substringAfter("patient_").substringAfter("_").toLong()
navController.navigate(Patient(name, id))
// `onWasmReady` ensures initialization in Kotlin/JS, not required in Kotlin/Wasm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be precise, onWasmReady is not available in Kotlin/Wasm at all, so this snippet won't compile when copied as is and pasted in kotlin/wasm source set.

I understand that duplicating this snippet is not good. Maybe the comment could specify this distinction between k/js and k/wasm.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which I prefer, because people can and will copy-paste this without reading and be upset when it doesn't work.

@ElviraMustafina I would separate the JS and Wasm code clearly, maybe collapsing both of the big code blocks. But tell me how you see it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added separate, switchable tabs for Kotlin/Wasm and Kotlin/JS code.

@@ -63,7 +63,8 @@ Users can use the **Back** and **Forward** buttons in the browser to move betwee
as well as use the address bar to understand where they are and get to a destination directly.

To bind the web app to the navigation graph defined in your common code,
call the `window.bindToNavigation()` method in your Kotlin/Wasm or Kotlin/JS code:
you can use the `window.bindToNavigation()` method in your Kotlin/Wasm code. For Kotlin/JS, ensure this code runs within
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expand a tiny bit here: something like "you can use the same method in Kotlin/JS, but make sure to wrap the code..."

```
<!--{default-state="collapsed" collapsible="true" collapsed-title="val initRoute = window.location.hash.substringAfter( ..."}-->
fun main() {
onWasmReady {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would still be great to comment on what this actually does — here, or at the top, where we mention it for the first time. Or both :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants