livereload

package
v0.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 4 Imported by: 0

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

View Source
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 FileChange struct {
	Action string
	Files  []string
}

type LiveReload

type LiveReload struct {
	// contains filtered or unexported fields
}

LiveReload keeps track of connected browser clients and broadcasts messages to them

func New

func New() *LiveReload

New creates a new LiveReload struct

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL