callback

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotSupport is returned when the callback handler does not support
	// the callback format.
	ErrNotSupport = fmt.Errorf("no support")
)

Functions

func Notify

func Notify(in <-chan map[string][2]string, out chan<- map[string][2]string)

Notify calls the callback handlers in turn to notify the app that the value has been changed.

Types

type Callback

type Callback interface {
	// Callback is the handler to parse the callback address and send
	// the notification.
	//
	// The second argument, value, is the changed and new value.
	//
	// If the implementation cannot parse or handle the callback, it should
	// return an error, ErrNotSupport.
	Callback(callback string, value string) error
}

Callback defines an interface of the callback notification handler.

func RegisterCallback

func RegisterCallback(name string, callback Callback) (old Callback)

RegisterCallback registers a callback notification handler with a name.

Notice: If the name has been registered, it will replace the old one and return it. If callback is nil, it will panic.

type CallbackFunc

type CallbackFunc func(callback string, value string) error

CallbackFunc converts a function to Callback.

func (CallbackFunc) Callback

func (c CallbackFunc) Callback(callback, value string) error

Callback implements the interface Callback.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL