Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

License

Notifications You must be signed in to change notification settings

massive-oss/msignal

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 7

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.