Mentions légales du service

Skip to content

Resolve "runBlocking is not available in JavaScript"

Yannick Li requested to merge 19-runblocking-is-not-available-in-javascript into master

The CServiceAdapter is used by the C-Client to make HTTP requests to the C-Service.
For this purpose, we use Ktor. Ktor is a Kotlin asynchronous framework that includes a flexible asynchronous HTTP client.

In the beginning, we intended to make synchronous requests in the C-Client thanks to runBlocking coroutine builder. The problem is that we are using Kotlin Multiplatform but runBlocking is not available in Kotlin/JS. See Kotlin Github.

To solve this problem with Kotlin/JS, we tried to directly use synchronous requests using XMLHttpRequest of Javascript. But synchronous requests are bad practice and gradually deprecated. See Spec, Mozilla or Google Chrome.

Finally, we decided to modify the code to deal with asynchronous HTTP requests of Ktor. It's recommended and it's better because CRDTs are designed to deal with this kind of problem.

Closes #19 (closed)

Edited by Yannick Li

Merge request reports

Loading