Reloading like Play
See original GitHub issueI see the following related issues:
However from my experience with sbt-revolver that’s not quite what Play offers.
In development mode, Play starts a server for you, before the sources are even compiled. Only once you hit the server via the web browser, does it compile and start up the application. Likewise, a source code change does not trigger a restart. Once sources are changed, AND you reload, that’s when the recompilation happens.
I continue to use Play despite having http4s and akka-http available because I don’t enjoy the reloading cycle using eager compilation. Why? I save the sources, Alt-Tab to the browser, refresh, and… bam! “Could not connect to the server”. So you then have to line up with the compiler in terms of waiting times, until you can finally Refresh the page.
With Play, you save the code, Alt-Tab, Refresh, and just wait for your page to load. Lower cognitive load, much more pleasant to deal with.
So I’d like to keep this issue open, based on the understanding that the others have not answered the question exactly. Play starts a server in background and recompiles on demand.
While I am all for libraries, this one thing that is enforced by the fact that Play is a framework makes it an absolute delight to use, despite its non-uniform non-FP nature.
I’m even wondering if it’s possible to embed an http4s route in Play. That’d provide an incremental adoption from Play crowd of http4s - instead of having to throw away all your Play code in one big go. Try with one endpoint, then two, and eventually all.
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Enter to stop and go back to the console...)
[info] Compiling 1 Scala source to /.../target/scala-2.12/classes ...
[info] Done compiling.
[info] play.api.Play - Application started (Dev)
[info] Compiling 1 Scala source to /.../target/scala-2.12/classes ...
[info] Done compiling.
--- (RELOAD) ---
[info] play.api.Play - Application started (Dev)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
For anyone interested, while this issue has not gone away by itself, I found a much happier solution; sbt-revolver + browser-sync.
I wrote a small http4s plug-in for browser-sync. It’s not documented very much, but if anybody is interested,
Sources @ https://github.com/ScalaWilliam/rad4s/blob/master/http4s-browsersync/src/main/scala/com/scalawilliam/rad4s/BrowserSync.scala
This would reStart the app, and then reload your browser window once it’s started up.
funny, that’s the one thing where i very much prefer using sbt-revolver over what play does - change some code, switch to the browser, hit reload - and instead of of just giving me the page, it lets me wait for ages until it finally finished compiling it 😃