An ECS based Signal. (another not needed signal "library")

ECS-Signal

A relatively quick Signal “library”. Yes, it uses Entity Component System.
It is not intended for public use and mainly shows my point of view on Signal pseudo class.

This pseudo class does not have any primary goals (aka be fastest or something like that).

The code explained by commentaries (I think).

Source is here.

Contains:

Signal object :

Connect : (callback) → Connection --Links a callback to a Signal. Returns connection object.

Fire : (…:any) → () --Fires a signal, running every linked callback.

NativeFire : (…any) → () --Fires every linked callback in synchronous way: yield functions will make it less efficient.

StaticConnect : (callback) → () --Links a callback to a Signal. This callback can not be disconnected.

Connection object:

Disconnect : () → () --Disconnects a connection.

Pros:

Quick thread pool;

Quick Fire and Connect functions;

Uses arrays and ECS;

Cons:

Works badly with yielding functions (task.wait, wait and coroutine.yield);

This is very basic Signal template;

Memory consumption might be (relatively) heavy;

Will not give you types in callback functions.

It might receive updates when I’ll find problems in my own projects.

4 Likes

An update.

Consists of:
Few incorrectness fixes
A types for signals (via generics)
Added xpcall() for NativeFire and coroutine fire so it’ll output errors.