Class: IfZero

system.logics. IfZero


new IfZero(value, thenTask, elseTask, elseTask)

Perform some tasks based on whether a given value is 0.

Parameters:
Name Type Description
value Object

The value to evaluate.

thenTask system.process.Action

The action to execute if the main condition if true.

elseTask system.process.Action

The action invoked if all the conditions failed.

elseTask array

The optional collection of system.logics.ElseIf tasks.

See:

Extends

Members


<readonly> elseIfTask :array

The collection of condition/action invokable if the main rule is not true.

Type:
  • array
Inherited From:

<readonly> elseTask :system.process.Action

The action invoked if all the conditions failed.

Type:
Inherited From:

<readonly> errorIt :system.signals.Signal

This signal emit when the action failed.

Type:
Inherited From:

<constant> finishIt :system.signals.Signal

This signal emit when the action is finished.

Type:
Inherited From:

<readonly> phase :string

Indicates the current phase.

Type:
  • string
Inherited From:
See:

rule :system.rules.Rule

The rule reference of this task.

Type:
Inherited From:

<readonly> running :boolean

Indicates action is running.

Type:
  • boolean
Inherited From:

<constant> startIt :system.signals.Signal

This signal emit when the action is started.

Type:
Inherited From:

thenTask :system.process.Action

The action to execute if the main condition if true.

Type:
Inherited From:

throwError :boolean

Indicates if the class throws errors or notify a finished event when the task failed.

Type:
  • boolean
Inherited From:
Default Value:
  • false

Methods


addElse(action)

Defines the action when the condition block use the else condition.

Parameters:
Name Type Description
action system.process.Action

The action to defines with the else condition in the {system.logics.IfTask} reference.

Inherited From:
Throws:

Error if an 'else' action is already register.

Returns:

The current IfTask reference.


addElseIf(condition)

Defines an action when the condition block use the elseif condition.

Parameters:
Name Type Description
condition system.logics.ElseIf | system.rules.Rule | system.process.Action

A {system.logics.ElseIf} instance or a serie of {system.rules.Rule}/{system.process.Action}.

Inherited From:
Returns:

The current IfTask reference.

Example
var IfTask      = system.logics.IfTask ;
var Do          = system.process.Do ;
var ElseIf      = system.logics.ElseIf ;
var EmptyString = system.rules.EmptyString ;
var Equals      = system.rules.Equals ;

var do1 = new Do() ;
var do2 = new Do() ;
var do3 = new Do() ;
var do4 = new Do() ;

do1.something = function() { trace("do1 ###") } ;
do2.something = function() { trace("do2 ###") } ;
do3.something = function() { trace("do3 ###") } ;
do4.something = function() { trace("do4 ###") } ;

var task = new IfTask() ;

task.addRule( new Equals(1,2) )
    .addThen( do1 )
    .addElseIf
    (
        new ElseIf( new Equals(2,1) , do3 ) ,
        new Equals(2,2) , do4
    )
    .addElse( do2 )
    .run() ; // do4 ###

addRule(rule)

Defines the main conditional rule of the task.

Parameters:
Name Type Description
rule system.rules.Rule

The main Rule of the task.

Inherited From:
Throws:

Error if a 'condition' is already register.

Returns:

The current IfTask reference.


addThen(action)

Defines the action when the condition block success and must run the 'then' action.

Parameters:
Name Type Description
action system.process.Action

Defines the 'then' action in the IfTask reference.

Inherited From:
Throws:

Error if the 'then' action is already register.

Returns:

The current IfTask reference.


clear()

Clear all elements conditions and conditional tasks in the process.

Inherited From:
Returns:

The current IfTask reference.


clone()

Creates a copy of the object.

Inherited From:
Returns:

a shallow copy of this object.


deleteElse()

Removes the 'else' action.

Inherited From:
Returns:

The current IfTask reference.


deleteElseIf()

Removes the 'elseIf' action.

Inherited From:
Returns:

The current IfTask reference.


deleteRule()

Removes the 'rule' of the task.

Inherited From:
Returns:

The current IfTask reference.


deleteThen()

Removes the 'then' action.

Inherited From:
Returns:

The current IfTask reference.


isLocked()

Returns true if the object is locked.

Inherited From:
Implements:
Returns:

true if the object is locked.


lock()

Locks the object.

Inherited From:
Implements:

notifyError()

Notify when the process is started.

Inherited From:

notifyFinished()

Notify when the process is finished.

Inherited From:

notifyStarted()

Notify when the process is started.

Inherited From:

run()

Run the process.

Inherited From:

unlock()

Unlocks the object.

Inherited From:
Implements: