turbo

package
v0.0.0-...-6c99bb1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Turbo Action type, Value can be APPEND|PREPEND|REPLACE|UPDATE|REMOVE

const (
	APPEND  Action = "append"
	PREPEND Action = "prepend"
	REPLACE Action = "replace"
	UPDATE  Action = "update"
	REMOVE  Action = "remove"
)

type Client

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

Client is a middleman between the websocket connection and the hub.

type Hub

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

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub() *Hub

NewHub Create a new hub, Hub keep track of all connected clients

func (*Hub) Run

func (h *Hub) Run()

Run Start the Hub, Running HUb broadcast messages to all connected hubs

type Stream

type Stream struct {
	Action   Action
	Template *template.Template
	Target   string
	Data     chan interface{}
}

Stream Create a new Turbo stream with Action and Data channel.

func (*Stream) Stream

func (s *Stream) Stream(hub *Hub, rw http.ResponseWriter, req *http.Request)

Stream start streaming messages to all hub clients

type Turbo

type Turbo struct {
	Action   Action
	Template *template.Template
	Target   string
	Data     interface{}
}

Turbo Create a new Turbo update

func (*Turbo) Send

func (h *Turbo) Send(rw http.ResponseWriter)

Send sends turbo template as HTTP response

func (*Turbo) SetHeader

func (h *Turbo) SetHeader(rw http.ResponseWriter)

type Update

type Update struct {
	Action   Action
	Template *template.Template
	Target   string
	Data     interface{}
}

func (*Update) Send

func (u *Update) Send(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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