Restart scala.js runtime environment
See original GitHub issueWe build all our scala.js apps with cats-effect 3 starting with IOApp
which is exported to the js runtime. e.g.
https://github.com/gemini-hlsw/explore/blob/fef6caaafdafa144b6a9ae04afad18990467e132/explore/src/main/scala/explore/Explore.scala#L61
This works fine for the regular browser case and node but has some restrictions when doing development on browser. There we often want to use HMR (Hot module replacement) where the dev environent detects changes to the compiled scala.js output and reloads the js code without a browser reload.
In practice this means we call IOApp.main
again, however the code below can only be ever called once.
https://github.com/typelevel/cats-effect/blob/series/3.x/core/js/src/main/scala/cats/effect/IOApp.scala#L33
Would it be possible to add a method that could be called on replacement to reset the environment such that another call to IOApp.main
wouldn’t fail?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
I wouldn’t expect to call it from java on my use case of HMR. And it would need to be a kind of
end-of-the-world
call returningUnit
to be exported easily to jsI think this is sufficiently addressed as of #2114. If you disagree, leave a comment and I’ll reopen!