Any good intro on coroutine scope in Kotlin JS? I ...
# javascript
t
Any good intro on coroutine scope in Kotlin JS? I want to use scope limited to JS/HTML page lifecycle instead of GlobalScope.
a
corountineScope
behave the same on any platform. So, you can use any previous knowledge you have on them Only thing different is that there is only one dispather in JS. Which makes sense since JS is single threaded
t
ok so GlobalScope is fine to use? Do we have any scope to use per page which make sure that coroutine scope is attached to the page, once we move away from page coroutine automatically destroyed?
@andylamax
a
highly depends. If you are rendering your pages on client side, then you would like to create a
CoroutineScope
on each page. If you are rendering each page from the server, then
GlobalScope
can be used.
Tell me more so that I can help. Is your code rendered in the server or the client?
t
@andylamax am little confused about this terminology. Basically I have static html pages and am rendering react application targeting the div in that static webpage.
@andylamax I can call you if you have time.
a
If you are using react, then you are doing rendering on the client side. You should then create a
CoroutineScope
inside a component you need to call suspend functions from
t
ok got it, I will check.
thank you
a
I can call you if you have time
Sure, I can use a 5 minute break
t
Thank you @andylamax
👍 1