ProAct.ActorUtil Class
src/js/core/actor_util.js:6
ActorUtil provides methods that can be used to make the Actor to 'act'.
The Actor is ProAct.js version of the base Observable
object. Various types
of listeners can be attached to it and used to observe its actions
.
On the other hand the Actor
should do something or act
, because something
has to be observed after all.
The ActorUtil
contains a set of methods that help implementing these acts
.
For example the we can trigger events/values in the Streams
. This is thier act
.
This triggering can be implemented with ease using the methods defined in ActorUtil
.
Another example is Properties
- they can be set or updated by the reactive flow -> they should react.
So ActorUtil
provides the Actors
with helpful methods for acting
and reacting
.
All these methods use the ProAct.Flow to defer the changes the right way.
And the using the flow
these methods handle the dependencies between the Actors
.
Use the methods in the ActorUtil
to implement your Actor's
actions
and reactions
.
Methods
doUpdate
-
[source]
-
[actions]
-
[eventData]
Contains the real notify/update logic defered by update into the flow.
It is private method, should not be used - use update
.
Parameters:
Returns:
The calling object.
update
-
[source]
-
[actions]
-
[eventData]
Updating/notifying method that can be applied to an ProAct.Actor
This method defers the update and the notifications into ProAct.flow.
If the state of the caller is ProAct.States.destroyed), an exception will be thrown. If the state of the caller is ProAct.States.closed), nothing will happen.
Examples:
You can implement a stream and in it's trigger
method use this:
ActorUtil.update.call(this, event);
This way the event will be triggered into the stream and all the listeners to the stream will be notified.
For this to work you'll have to override the makeEvent
method of the stream to return the unmodified source - no state/no event generation,
the event will just go through.
If you want to implement a statefull Actor
like a property
, you can set a state in it and just notify all the
observing Actors
with this method.
Parameters:
Returns:
The calling object.