npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

luau-signal

v0.1.0

Published

A simple signal utility

Downloads

38

Readme

Luau Signal

A typed Luau signal library.

Signals are a lightweight communication mechanism used to facilitate the exchange of information between different components or modules of a software system. Signals allow parts of a program to notify others without having a dependency on them. This decoupled approach promotes modularity, making it easier to manage and maintain complex systems by broadcasting data in messages without requiring direct knowledge of their recipients.

Installation

Add luau-signal in your dependencies:

yarn add luau-signal

Or if you are using npm:

npm install luau-signal

Example

local Signal = require('@pkg/luau-signal')

-- re-declare the type for easy access
type Signal<T...> = Signal.Signal<T...>

-- create the signal and optionally declare its type
local mySignal: Signal<string> = Signal.new()

local connection = mySignal:connect(function(param: string)
    print("Signal received:", param)
end)

-- fire the signal
mySignal:fire("Hello, World!")

-- disconnect the callback
connection:disconnect()

API

Signal

Signal.new<T...>(): Signal<T...>

Creates a new signal instance.

Signal:fire<T...>(...: T...)

Fires the signal, triggering all connected callback functions with the provided arguments.

Signal:connect<T...>(callback: (T...) -> ()): Connection

Connects a callback function to the signal and returns a connection object. This object can be used to disconnect the callback later.

Connection

Connection:disconnect() -> ()

Disconnects the connection, preventing the associated callback function from being called when the signal fires.

Connection:disconnectFn() -> () -> ()

Returns a function that, when called, disconnects the connection or throw an error if it has already been disconnected.

Connection:disconnectOnceFn() -> () -> ()

Returns a function that, when called, checks if the connection is still active before disconnecting it. The returned function will not throw.

Releases

Versions of the library are also pre-built and linked to GitHub releases:

  • signal.rbxm is a Roblox model file
  • signal-roblox-bundled.lua is a single-file version of the library (with Luau type annotations removed)

Other Lua Environments Support

If you would like to use this library on a Lua environment, where it is currently incompatible, open an issue (or comment on an existing one) to request the appropriate modifications.

The library uses darklua to process its code.