msignal

A Haxe port of the ActionScript 3 Signals library that leverages Haxe type parameters. Supports AVM1, AVM2, JavaScript, Neko and C++.

  • Owner: massive-oss/msignal
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Overview

Signals are highly scalable and lightweight alternative to Events.

msignal.Signal is a type safe port of Robert Penner’s AS3 Signals leveraging Haxe generics.

Benefits:

  • Avoids costly native event bubbling on different platforms (e.g. HTML DOM events) that impact performance
  • Type safe signature for dispatching and observer handlers
  • Typing excluded from output (lighter, cleaner code without compromising integrity)

You can download some examples of msignal usage here.

Importing

All required classes can be imported through msignal.Signal

import msignal.Signal;

Basic usage

var signal = new Signal0();
signal.add(function(){ trace("signal dispatched!"); })
signal.dispatch();

Extending

class MySignal extends Signal2<String, Int>
{
	public function new()
	{
		super();
	}
}

Typed parameters

var signal = new Signal1<String>();
signal.add(function(i:Int){}); // error: Int -> Void should be String -> Void
signal.dispatch(true) // error Bool should be String

Numbers of parameters:

var signal0 = new Signal0();
var signal1 = new Signal1<String>();
var signal2 = new Signal2<String, String>();

Slots:

var signal = new Signal0();
var slot = signal.add(function(){});
slot.enabled = false;
signal.dispatch(); // slot will not dispatch

Slot parameters:

var signal2 = new Signal2<String, String>();
var slot = signal.add(function(s1, s2){ trace(s1 + " " + s2); });
slot.param1 = "Goodbye";
signal.dispatch("Hello", "Mr Bond"); // traces: Goodbye Mr Bond

Main metrics

Overview
Name With Ownermassive-oss/msignal
Primary LanguageHaxe
Program languageHaxe (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2012-07-30 01:57:14
Pushed At2022-07-03 15:08:59
Last Commit At2018-12-26 17:59:31
Release Count7
Last Release Name1.2.5 (Posted on )
First Release Name1.1.2 (Posted on )
用户参与
Stargazers Count78
Watchers Count91
Fork Count26
Commits Count66
Has Issues Enabled
Issues Count14
Issue Open Count5
Pull Requests Count4
Pull Requests Open Count1
Pull Requests Close Count5
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private