# flow


03/13/2023, 7:01 PM
Hi. Does
work correctly on JS? For examlpe I have such test
Copy code
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals

class Learning {

    fun someRandomLearningTest() = runTest {
        val someRandomScope = CoroutineScope(Dispatchers.Default)
        val selectedFiles = MutableStateFlow(123)
        val minimumAmountOfVideoClicks = MutableStateFlow(123)

        val data = selectedFiles.combine(minimumAmountOfVideoClicks) { i: Int, i1: Int -> i + i1 }
            .onEach { println("--- before debounce") }
            .onEach { println("--- after debounce") }
            .stateIn(someRandomScope, SharingStarted.Lazily, 0)

        assertEquals(60516, data.take(2).last())
        assertEquals(60516, data.first())

    private fun doSomeWork(n: Int): Int {
        return n * n
On JVM it runs okay. but on JS it shows error in Intellij and on browser(while using it in my project) it shows a bit different error. So am I doing it wrong or how can I fix it so it works as on JVM?