https://kotlinlang.org logo
#reaktive
Title
# reaktive
m

Mina Eweida

06/18/2020, 3:18 PM
Hi @Arkadii Ivanov I have a question regarding the fix regarding javascript https://github.com/badoo/Reaktive/pull/486 When it gets approved and merged, when will you plan to release it?
a

Arkadii Ivanov

06/18/2020, 10:51 PM
Hey! I noticed some new commits. I will review them tomorrow. In general we need to get to the bottom before approval. A new version will be released right after merge.
Reviewed the changes, please check
m

Mina Eweida

06/19/2020, 9:53 AM
Sorry just seen your comment. I actually simplified the PR and removed the files I created. I will think of a test to run for js, pretty much this issue should have shown up if
MainScheduler
was running on a test, so I will just try to run a test using it and see if it crashes then will run it with my change and see
The fix I just pushed works fine on my sample nodeJs app, note that it’s actually written in javascript not Kotlin so what I am doing is actually locally npm publishing my library’s package and Reaktive
Actually my assumption did not work.
Copy code
@Test
    fun test_main_scheduler_subscription() {
        val emitted = 10
        val upstream = observable<Int> {
            it.onNext(emitted)
        }.subscribeOn(mainScheduler)
        upstream.subscribe {
            assertEquals(emitted, it)
        }
    }
This tests works fine with both
globalThis
and
window
when running
jsNodeTest
😞
a

Arkadii Ivanov

06/19/2020, 11:13 AM
Hey, the following test fails with
ReferenceError
in current master:
Copy code
@Test
fun submits_task_to_executor() {
    val scheduler = MainScheduler()
    val executor = scheduler.newExecutor()
    executor.submit {}
}
So if you could attach this to your PR that would be great!
So the
jsBrowserTest
task passes but the
jsNodeTest
fails
m

Mina Eweida

06/19/2020, 11:15 AM
Woww, thank you, it actually passed for me. I don’t get the difference though. I mean I used
mainScheduler
and subscription actually called
submit
in the
mainScheduler
and I was able to see it (I printed inside submit)
Amended my commit
a

Arkadii Ivanov

06/19/2020, 11:17 AM
Perhaps in your case the error is handled by `
Copy code
reaktiveUncaughtErrorHandler
which in JS just prints the error.
Thanks
m

Mina Eweida

06/19/2020, 11:18 AM
no it can’t because if it’s the case then why did my test pass, I mean it could be silently catching the exception but still I asserted on the emission
technically it is posted so test might have ended before emission that’s why it showed that it passed
a

Arkadii Ivanov

06/19/2020, 11:20 AM
I mean in your case the subscription stage failed and the error was catched by the
reaktiveUncaughtErrorHandler
. The
susbcribe{}
was never called and so test passed.
m

Mina Eweida

06/19/2020, 11:21 AM
yes makes sense
Copy code
Submitting 0
[error] ReferenceError: window is not defined
that was the case in fact 😄
👍 1
a

Arkadii Ivanov

06/19/2020, 1:09 PM
Thanks for the PR!