# Luakit Documentation / Modules / lousy.signal

# Module `lousy.signal`

lousy.signal library

Mimic the luakit signal API functions for tables.

## Functions

### lousy.signal.add_signal (object, signame, func)

Add a signal handler to an object, for a particular signal.

When a signal with the given name is emitted on the given object with `emit_signal()`, the given callback function will be called, along with all other signal handlers for the signal on the object.

The first argument passed to the callback function will be the object this signal is emitted on (`object`), unless this object was setup for signals with `module=true`, i.e. as a module object. In that case, the object will not be passed to the callback at all. Subsequently, the callback function will receive all additional arguments passed to `emit_signal()`.

`object` must have been set up for signals with `setup()`.

#### Parameters

- object
  Type: any type
  The object on which to listen for signals.
- signame
  Type: string
  The name of the signal to listen for.
- func
  Type: function
  The signal handler callback function.

### lousy.signal.emit_signal (object, signame, ...)

Emit a signal on an object.

`object` must have been set up for signals with `setup()`.

#### Parameters

- object
  Type: any type
  The object on which to emit the signal.
- signame
  Type: string
  The name of the signal to emit.
- ...
  Type: any type
  Additional arguments are passed any signal handlers called.

### lousy.signal.remove_signal (object, signame, func)

Remove a signal handler function from an object.

`object` must have been set up for signals with `setup()`.

#### Parameters

- object
  Type: any type
  The object on which to remove a signal handler.
- signame
  Type: string
  The name of the signal handler to remove.
- func
  Type: function
  The signal handler callback function to remove.

#### Return Values

- function
  Returns the removed callback function, if the signal handler was found.
- nil
  If the signal handler was not found.

### lousy.signal.remove_signals (object, signame)

Remove all signal handlers with a given name from an object.

#### Parameters

- object
  Type: any type
  The object on which to remove a signal handler.
- signame
  Type: string
  The name of the signal handler to remove.

### lousy.signal.setup (object, module)

Setup an object for signals.

Sets up the given object for signals, and returns the object.

If `module` is `true`, then the object is not passed to signal callback functions as the first parameter when a signal is emitted.

`object` must not have been set up for signals with `setup()`.

#### Parameters

- object
  Type: any type
  The object to set up for signals.
- module
  Type: boolean
  Whether this object should be treated as a module.

#### Return Values

- any type
  The given object.

## Attribution

#### Copyright

- 2010 Fabian Streitel
- 2010 Mason Larobina