Skip to content
do- edited this page Dec 28, 2022 · 94 revisions

Job is a class of single-use objects created for each execution of a business method (from Application's ModuleMap).

Its name means "jobs" in Queueing theory, not Oracle Database's periodic tasks.

This class implements the basic workflow used in all doix based server applications. It's presumed to never be inherited from, only extended by setting event handlers.

Job instances are mostly passive objects: other pieces of code get and set their properties, subscribe to events and so on. Only two methods are exposed to be called from elsewhere.

Properties

Name Description
app the Application instance this job belongs to
rq request parameters, an an Object. Think PHP's $_REQUEST generalization. Setting rq is the way of passing parameters to the business method to be called in the context of this job.
module business method containing module: the value fetched from Application's ModuleMap by MethodSelector's getModuleName () result.
result the result returned by the business method and to be returned by toComplete (). But result event handlers may rewrite it.
error the error thrown by the business method and to be thrown by toComplete (). But error event handlers may rewrite it. In particular, if this.error finally gets undefined, toComplete () returns undefined instead of throwing anything.

Methods

toComplete ()

This asynchronous method implements the job's lifecycle:

  • setting module from Application's ModuleMap by MethodSelector's getModuleName () result
  • calling its method named getMethodName () (the business method) with the job itself visible as this and then
    • if it throws something, set it to error and rethrow;
    • set the value returned to result and return it otherwise.

waitFor (promise)

Events

Clone this wiki locally