Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of a FlxSignal in action.
import flixel.util.FlxSignal;
// for signals that don't need data, use FlxSignal
var signal = new FlxSignal();
// for signals that need data, use FlxTypedSignal with the correct function type
var stringSignal = new FlxTypedSignal<String->Void>();
function noParamCallback() {
trace('Dispatched void event');
}
function showTextCallback(value:String) {
trace(value);
}
//Registering the callbacks
signal.add(noParamCallback);
stringSignal.add(showTextCallback);
stringSignal.add((x)->{trace(x + " Not so good");});
//Sending out the event
stringSignal.dispatch('Hello World'); //Prints Hello World and also 'Hello World Not so good'
signal.dispatch(); //Prints Dispatched Event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment