Skip to content

Instantly share code, notes, and snippets.

Last active Apr 19, 2022
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) {
//Registering the callbacks
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