autorefresh

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go Reference

browser-autorefresh

This is a small Golang utility that can be installed as part of a web server that facilitates browser page auto-refresh when the service is restarted via some live-relaod function

There are two components this utility provides:

  1. An http handler for a websocket endpoint
  2. A template that provides a JS script to include in a page's html that uses the websocket endpoint to detect when the server is operational.

When the websocket connection is lost, a retry on the client-side occurs until it is able to reconnect, at which point it reloads the page to pull in the latest changes.

This is most useful when combined with a server live reload tool (e.g., (air)[https://github.com/air-verse/air]).

Installation

go get github.com/lavigneer/browser-autorefresh

Example

See examples/std

Documentation

Overview

Package autorefresh provides a mechanism for attaching browser refreshing to your templates during development. When it is detected that your program has restarted (e.g., by using a live-reload tool like "air"), it will trigger the browser page to refresh itself automatically.

Index

Constants

View Source
const Script string = `` /* 572-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type PageReloader

type PageReloader struct {
	Template    *template.Template
	Path        string
	RefreshRate uint
}

func New

func New(t *template.Template, path string, refreshRate uint) (*PageReloader, error)

func (*PageReloader) ServeHTTP

func (p *PageReloader) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
examples
std command

Jump to

Keyboard shortcuts

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