Documentation
¶
Overview ¶
Package livereload implements HTML5 Server Side Events to live reload connected browsers Usage: first start the livereload instance
liveReload := livereload.New() liveReload.Start()
then, install an HTTP handler on desired path
http.Handle("/livereload", liveReload)
then, reload the connected browsers
liveReload.Reload()
The target browser must support HTML5 Server Side Events. Note: In Chrome and Firefox - there is a limit of 6 active connections per browser + domain. Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=275955 Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=906896
Index ¶
Constants ¶
const JsSnippet = `` /* 766-byte string literal not displayed */
JsSnippet is a minimal javascript client for browsers. Embed it in your index.html using a script tag:
<script>{{ LiveReload.JsSnippet }}</script>
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileChange ¶ added in v0.4.5
type LiveReload ¶
type LiveReload struct {
// contains filtered or unexported fields
}
LiveReload keeps track of connected browser clients and broadcasts messages to them
func (*LiveReload) Error ¶
func (livereload *LiveReload) Error(msg string)
func (*LiveReload) Reload ¶
func (livereload *LiveReload) Reload(files []string)
Reload sends a reload signal to all connected browsers
func (*LiveReload) ServeHTTP ¶
func (livereload *LiveReload) ServeHTTP(res http.ResponseWriter, req *http.Request)
ServeHTTP is a request handler for http requests
func (*LiveReload) Start ¶
func (livereload *LiveReload) Start()
Start manages connections and broadcasts messages to connected clients