controller

package
v0.0.0-...-9292203 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package controller manages bindings with a model, and provides mutation methods

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadPair = errors.New("bad pair")
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Browser wsrpc.Browser
	// contains filtered or unexported fields
}

Controller handles the interaction of observable bindings between the model and the browser. It also handles action bindings with clickable objects.

func New

func New(server *wsrpc.Server, browser wsrpc.Browser, namespace string) *Controller

New creates a new Controller instance given the web server's RPC service and a connection to the browser. namespace specifies the browser's binding namespace to use with this Controller's instance.

func Start

func Start(ctx context.Context, ws *websocket.Conn) (c *Controller, done <-chan struct{}, err error)

Start starts server side rpc and creates a Controller. wait on the returned channel after creating your bindings.

func (*Controller) BindAction

func (c *Controller) BindAction(element, action string) error

BindAction creates an action binding. Call HandleActions first.

func (*Controller) BindActions

func (c *Controller) BindActions(pairs ...string) error

BindActions calls BindAction with multiple pairs of element,action as a convenience

func (*Controller) BindValues

func (c *Controller) BindValues(
	name string,
	formID string,
	elements []string,
	source observable.Source,
) error

BindValues creates value bindings.

func (*Controller) HandleActions

func (c *Controller) HandleActions(handler func(action string))

HandleActions sets the callback for actions

func (*Controller) Release

func (c *Controller) Release()

Release removes all bindings

Jump to

Keyboard shortcuts

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