ValueDispatcher
class
ValueDispatcher
T
extends
EventDispatcherBase
T
Dispatches a
SubscribableValueEvent
Changing the value stored by a value dispatcher will immediately notify allits subscribers.
Examples
Type Parameters
-
TThe type of the value passed to subscribers.
Constructors
constructor
Type Parameters
Parameters
-
value : TThe initial value.
EventDispatcherBase.constructor
Properties
subscribable
readonly
public
subscribable
:
SubscribableValueEvent
T
=
...
Accessors
current
public
set
current
value
:
T
:
void
public
get
current
():
T
Set the current value of this dispatcher.
Setting the value will immediately notify all subscribers.
Parameters
-
value : TThe new value.
Methods
clear
public
clear
():
void
Unsubscribe all subscribers from the event.
Inherited from
EventDispatcherBase.clear
subscribe
public
override
subscribe
handler
:
EventHandler
T
dispatchImmediately
:
boolean
=
true
: () =>
void
Subscribe to the event.
Subscribing will immediately invoke the handler with the most recent value.
Parameters
-
handler : EventHandler TThe handler to invoke when the event occurs.
-
dispatchImmediately : boolean = trueWhether the handler should be immediatelyinvoked with the most recent value.
EventDispatcherBase.subscribe
unsubscribe
public
unsubscribe
handler
:
EventHandler
T
:
void
Unsubscribe from the event.
Parameters
-
handler : EventHandler TThe handler to unsubscribe.
EventDispatcherBase.unsubscribe