signal

package
v0.0.0-...-ba7cdbd Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2014 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package signal implements functions for emitting and receiving signals on events. Gondola provides some builtin signals, but users can define additional ones

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(name string, object interface{})

Emit calls all the listeners for the given signal.

func Stop

func Stop(name string, t *Token)

Stop removes a listener, previously registered using Listen. The first argument indicates the signal name. If it's empty, the listener will be removed for all the signal. The second argument is the token returned by Listen(). If it's empty, all the listeners for the given signals will be removed.

Types

type Token

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

func Listen

func Listen(name string, f interface{}) *Token

Listen adds a new listener for the given signal name. The second argument must be a function which accepts either:

- no paremeters - 1 parameter, which must be of type string - 2 parameters, the first one must be string and the second one, interface{}

If the function does not match the required constraints, Listen will panic.

The function will be called whenever the signal is emitted. The returned value is the token, which is required to unregister this listener. If you don't need to unregister it, you can safely ignore the first returned value.

Jump to

Keyboard shortcuts

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