Skip to content

YuiElina/Signal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Highly Optimized Signal Module

Overview

This module provides an optimized implementation of the signal pattern in Lua, designed for use in Roblox. It allows for efficient event handling with minimal conditionals, utilizing a linked list structure to manage connections.

Features

  • Supports multiple listeners for a single event.
  • Efficient connection and disconnection methods.
  • Safe error handling with pcall for callbacks.
  • Debouncing functionality to limit the firing rate of signals.

Installation

To use the Signal module in your Roblox game, place it in ReplicatedStorage or any other accessible location, then require it in your scripts.

local Signal = require(game.ReplicatedStorage:WaitForChild("Signal"))

Usage

Creating a Signal

local mySignal = Signal.new()

Connecting a Callback

local function myCallback(...)
    print("Signal fired with arguments:", ...)
end

local connection = mySignal:Connect(myCallback)

Firing a Signal

mySignal:Fire("Hello", "World")

Disconnecting a Callback

connection:Disconnect()

Disconnecting All Connections

mySignal:DisconnectAll()

Debounced Firing

mySignal:FireDebounced(1, "This will fire once per second.")

Contributing

Contributions are welcome! If you have suggestions for improvements or new features, feel free to create a pull request. Here are a few guidelines for contributing:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and test thoroughly.
  4. Submit a pull request with a clear description of your changes.

Notes

  • Ensure to manage connections properly to avoid memory leaks.
  • Utilize debouncing for frequent events to improve performance.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages