hot reload web handler

A Vert.x web handler for hot reload

License

License

GroupId

GroupId

xyz.jetdrone
ArtifactId

ArtifactId

hot-reload
Last Version

Last Version

0.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

hot reload web handler
A Vert.x web handler for hot reload
Source Code Management

Source Code Management

https://github.com/pmlopes/hot-reload

Download hot-reload

How to add to project

<!-- https://jarcasting.com/artifacts/xyz.jetdrone/hot-reload/ -->
<dependency>
    <groupId>xyz.jetdrone</groupId>
    <artifactId>hot-reload</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/xyz.jetdrone/hot-reload/
implementation 'xyz.jetdrone:hot-reload:0.0.5'
// https://jarcasting.com/artifacts/xyz.jetdrone/hot-reload/
implementation ("xyz.jetdrone:hot-reload:0.0.5")
'xyz.jetdrone:hot-reload:jar:0.0.5'
<dependency org="xyz.jetdrone" name="hot-reload" rev="0.0.5">
  <artifact name="hot-reload" type="jar" />
</dependency>
@Grapes(
@Grab(group='xyz.jetdrone', module='hot-reload', version='0.0.5')
)
libraryDependencies += "xyz.jetdrone" % "hot-reload" % "0.0.5"
[xyz.jetdrone/hot-reload "0.0.5"]

Dependencies

compile (1)

Group / Artifact Type Version
io.vertx : vertx-web jar 3.5.1

provided (4)

Group / Artifact Type Version
io.vertx : vertx-codegen jar 3.5.1
io.vertx : vertx-lang-js jar 3.5.1
io.vertx : vertx-lang-groovy jar 3.5.1
io.vertx : vertx-lang-ruby jar 3.5.1

Project Modules

There are no modules declared in this project.

hot-reload

This is a experimental vertx-web handler for hot reload. This handler is used in the webpack-vertx-plugin but it is not necessary to, you can also use it independently.

What's inside?

This module provides 2 handlers in one:

  • A hot-reload script + backend based either in SSE or pooling
  • A static file server (delegates to the official static file server)

hot-reload script

The script can listen for updates either as a SSE stream or using pooling. It defaults to SSE as it is supported on modern web browsers but for legacy it can be configured to perform HTTP pooling.

static handler

A static handler will be returned using this factory. If there is a file named .hot-reload on the current working directory then the static handler is configured to not cache both the filesystem and the http responses.

How to configure?

In your application router you should add the following code:

final Router router = Router.router(vertx);

// development hot reload
router.get().handler(HotReload.create());
...
// Serve the static resources
router.route().handler(StaticHandler.create());

When there isn't a file named .hot-reload in the current working directory the handler will be a NO-OP handler and the last will return a unmodified StaticHandler.

In your html application you should have:

<!DOCTYPE html>
<html>
<body>
  <script src="/hot-reload/script"></script>
</body>
</html>

How it works?

When you start your application you should have the control file in the current working directory e.g.:

touch .hot-reload
java -jar target/fatjar.jar

Navigate to your HTML page where you loaded the script, and after that update the contents of the reload control file e.g.:

echo "update!" >> .hot-reload

You will notice that a reload is triggered on the browser.

Versions

Version
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1