An open API service indexing awesome lists of open source software.

https://github.com/superzazu/signals.lua

Simple signals implementation in Lua.
https://github.com/superzazu/signals.lua

library observer-pattern signals

Last synced: about 1 year ago
JSON representation

Simple signals implementation in Lua.

Awesome Lists containing this project

README

          

# signals

signals is a simple signals module for Lua.

## Simple use
```
local signals = require "signals"

local monster = {is_alive=true}

signals.connect("player_hit_monster", function()
monster.is_alive = false
end)

signals.send("player_hit_monster")
print(monster.is_alive) -- false
```

## Use of groups

Sometimes, you'll probably want to disconnect a lot of signals at once:
```
local score = 0

signals.connect("player_hit_monster", function()
score = score + 10
end, "group1")
signals.connect("player_hit_monster", function()
score = score + 42
end, "group1")

signals.disconnectGroup("group1")
signals.send("player_hit_monster")
print(score) -- 0
```