Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dervexdev/advancedsignal
Advanced Signal lets you choose whether you prefer performance or ease of use
https://github.com/dervexdev/advancedsignal
Last synced: about 1 month ago
JSON representation
Advanced Signal lets you choose whether you prefer performance or ease of use
- Host: GitHub
- URL: https://github.com/dervexdev/advancedsignal
- Owner: DervexDev
- License: apache-2.0
- Created: 2023-06-23T14:51:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-19T21:12:59.000Z (over 1 year ago)
- Last Synced: 2024-05-02T05:30:01.173Z (8 months ago)
- Language: Lua
- Homepage: https://wally.run/package/dervexhero/advancedsignal
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Advanced Signal
Advanced Signal lets you choose whether you prefer performance or ease of use### About
Signal is not yieldable by default, so yielding inside one of its bindings will result in yielding rest of them. By default, the binding order is not preserved thus connection that were made first will be fired last. Behavior of these two things can be changed by providing additional arguments to Signal.new() or by changing globally DEFAULT_SETTINGS.### API Usage
```lua
local Signal = require(path.to.advancedsignal.module)-- Creates new signal class with optional settings
local signal = Signal.new(yieldable?, keepOrder?)-- Binds callback to the signal, returns connection
local handle = signal:Bind(function(params)
print(params)
end)-- Binds callback to the signal, will unbind automatically, returns connection
signal:Once(function(params)
print(params)
end)-- Fires signal with given arguments
signal:Fire(args)-- Unbinds a connection from the signal
handle:Unbind() or signal:Unbind(handle)-- Unbinds all connections from the signal
signal:UnbindAll()-- Yields current thread until signal is fired
signal:Wait()
```### Credits
Part of this code was written by @stravant