Packageorg.spicefactory.parsley.command
Classpublic class ManagedCommandBuilder
InheritanceManagedCommandBuilder Inheritance Object

A builder DSL for creating command instances that are managed by the container. This API adds on top of the standalone Spicelib Commands builder APIs the ability to let commands get managed by a Parsley Context during execution.



Public Methods
 MethodDefined By
  
Builds the target command without executing it, applying all configurations specified through this builder instance and associating it with the specified Context.
ManagedCommandBuilder
  
cancel(callback:Function):ManagedCommandBuilder
Adds a callback to invoke when the command gets cancelled.
ManagedCommandBuilder
  
Adds a value that can get passed to the command executed by the proxy this builder creates.
ManagedCommandBuilder
  
error(callback:Function):ManagedCommandBuilder
Adds a callback to invoke when the command produced an error.
ManagedCommandBuilder
  
Builds and executes the target command.
ManagedCommandBuilder
  
The identifier of the managed command.
ManagedCommandBuilder
  
result(callback:Function):ManagedCommandBuilder
Adds a callback to invoke when the command completes successfully.
ManagedCommandBuilder
  
timeout(milliseconds:uint):ManagedCommandBuilder
Sets the timeout for the command execution.
ManagedCommandBuilder
Method Detail
build()method
public function build(context:Context):ManagedCommandProxy

Builds the target command without executing it, applying all configurations specified through this builder instance and associating it with the specified Context.

Parameters

context:Context — Context that is responsible for managing the command created by this builder

Returns
ManagedCommandProxy — the command proxy will all configuration of this builder applied
cancel()method 
public function cancel(callback:Function):ManagedCommandBuilder

Adds a callback to invoke when the command gets cancelled. The callback should not expect any parameters.

Parameters

callback:Function — the callback to invoke when the command gets cancelled

Returns
ManagedCommandBuilder — this builder instance for method chaining
data()method 
public function data(value:Object):ManagedCommandBuilder

Adds a value that can get passed to the command executed by the proxy this builder creates.

Parameters

value:Object — the value to pass to the command

Returns
ManagedCommandBuilder — this builder instance for method chaining
error()method 
public function error(callback:Function):ManagedCommandBuilder

Adds a callback to invoke when the command produced an error. The cause of the error will get passed to the callback.

Parameters

callback:Function — the callback to invoke when the command produced an error

Returns
ManagedCommandBuilder — this builder instance for method chaining
execute()method 
public function execute(context:Context):ManagedCommandProxy

Builds and executes the target command. A shortcut for calling build().execute(). In case of asynchronous commands the returned proxy will still be active. In case of synchronous commands it will already be completed, so that adding event listeners won't have any effect.

Parameters

context:Context — Context that is responsible for managing the command created by this builder

Returns
ManagedCommandProxy — the command that was built and executed by this builder
id()method 
public function id(value:String):ManagedCommandBuilder

The identifier of the managed command. The id is optional and can be used for identifying matching command observers.

Parameters

value:String — identifier of the managed command

Returns
ManagedCommandBuilder — this builder instance for method chaining
result()method 
public function result(callback:Function):ManagedCommandBuilder

Adds a callback to invoke when the command completes successfully. The result produced by the command will get passed to the callback.

Parameters

callback:Function — the callback to invoke when the command completes successfully

Returns
ManagedCommandBuilder — this builder instance for method chaining
timeout()method 
public function timeout(milliseconds:uint):ManagedCommandBuilder

Sets the timeout for the command execution. When the specified amount of time is elapsed the command will abort with an error.

Parameters

milliseconds:uint — the timeout for the command execution in milliseconds

Returns
ManagedCommandBuilder — this builder instance for method chaining