-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add JS support #17
Comments
Differences between Apple native and JS:
Thanks @ankushg for the info! |
Hey, in our company we're planning a library that would compile to Android, iOS, and Web, and this would be very useful. Do you have an ETA on when Js support is planned? Alternatively, do you have an idea on how to use coroutines from Js temporarily? Maybe the simplest thing would be converting to RxJs? |
Hi! I don't really have an ETA for this at the moment and am currently not actively working on it to be honest 😅. However I would love to support JS as well. It's just that I am not really that familiar with JS and Kotlin/JS, so I am kind of lacking insights into the issues/challenges in terms of coroutines interop. For iOS/Swift the 2 main issues are cancellation support and the lack of generics on interfaces in ObjC. By any chance do you know of a sample JS project that uses a shared Kotlin module? Once we have a clear picture of the challenges it should be fairly easy to define a JavaScripty API to use coroutines from JS code 😄.
|
Hey @rickclephas, I have worked with Kotlin/Js before so maybe I can help out. Js is radically different from the others platform, it's single-threaded by default on the browser, they are using Workers to multithread. If I'm not incorrect you should be able to cancel a job in RxJs, I think if mapped correctly it might be our best bet. I have no Kotlin/Js project to share atm, but I imagine we can create a very simple sample project, with a number and 2 actions to increase or decrease the number shown on the screen. Following the BLoC pattern, the shared module would contain the shared code. We can use react to show a few widgets, and that's it. As you say, once we see the challenges shouldn't be hard to get it right. What do you say? |
Yeah that would be great! Adding it to this repo makes sense since a lot of the logic will be the same regardless of the platform. The biggest differences will be in the wrapper functions. It would be great if we could add a react "client" to the sample (with the clock and random letters views). |
I can maybe provide a PR when I got time |
If it helps https://github.com/joreilly/PeopleInSpace has a Kotlin/JS client (along with Compose for Web one)....it's already using this library for Kotlin/Native clients. |
Thanks @joreilly!! But that is all in Kotlin, right? In that case you can just use the coroutines code directly, no need for any wrappers 😄. The challenge would be in using the shared Kotlin module from plain JS code. |
ah, good point :) |
Not sure if this is the right issue, but I was trying some experiments with wasmJs and get a build error with this package (using ALPHA-15 atm). |
@tylerwilson this issues was/is actually about full support for JS (currently we only support projects with the JS target). |
JS and native share some limitations with the coroutines interop.
The generic way of exposing callbacks could be applied to JS as well.
Allowing the clients to decide on an appropriate "native coroutines implementation".
The text was updated successfully, but these errors were encountered: