A msignal-based event dispatcher class. Allows for easy setup of event dispatching. When cancelled, will stop next listeners invokation.

Use subclasses to create instances of EventSignal and call their dispatch function to invoke listeners.

Constructor

new ()

Variables

cancelled:Bool

True, when listeners cancel signal invokation. Prevents further listeners being invoked.

softCancelled:Bool

Will force dispatch function to return false and cancelled being true after call, but does not stop listener invokation.

Methods

@:value({ once : false, priority : 0 })add (listener:T, priority:Int = 0, once:Bool = false):Void

Adds new listeners to the list.

Parameters:

priority

A priority of the listener. Higher priority listeners are called first. Same priority events are called on first-come-first-served basis.

once

If true, will trigger listener only once and then automatically unsubscribe from the list.

cancel ():Void

Cancels futher listener invokation. Events further in listener list will not be invoked after this call. If called, cancelled will be true and dispatch will return false.

remove (listener:T):Bool

Removes listener from the list.

removeAll ():Void

softCancel ():Void

Cancels signal without preventing furhter listener invokation. If called, cancelled will be true and dispatch will return false.