Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ultra fast and small strict typed simple signals.
package ;
class FastSignalsExample {
static function main() {
var o = new Signal1<String>();
o.add(function(v) trace(v));
class Signal0 extends SCore<Void->Void> {
inline public function dispatch():Void for (e in list) e();
class Signal1<T> extends SCore<T->Void> {
inline public function dispatch(v:T):Void for (e in list) e(v);
class Signal2<A,B> extends SCore<A->B->Void> {
inline public function dispatch(a:A, b:B):Void for (e in list) e(a, b);
class Signal3<A,B,C> extends SCore<A->B->C->Void> {
inline public function dispatch(a:A, b:B, c:C):Void for (e in list) e(a, b, c);
class SCore<T> {
private var list:List<T>;
inline public function new() list = new List();
inline public function add(f:T):Void list.add(f);
inline public function remove(f:T):Void list.remove(f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment