Class: Job

Job(promiseProducer, nameopt)

The events emitted are (using the declared/exported symbols and the class JobEvent): - 'run' (immediately triggered before the job is run) - 'done' (if successfully ran to completion, includes the result) - 'failed' (if failed with an error, includes the error)

Constructor

new Job(promiseProducer, nameopt)

Parameters:
Name Type Attributes Description
promiseProducer producerHandler.<Promise.<T>> A function returning a Promise or an async function (essentially the same). If you want to use a sync function, call Job::fromSyncFunction(fn) instead.
name String <optional>
Optional. Defaults to undefined. Give an optional name to this job.
Author:
Source:
See:
  • {fromSyncFunction()}

Members

cost

Source:

cost

Source:

createTime

Source:

donePromise

A promise that can be used to await this Job's final state. If resolved, will resolve with this Job's result. The promise returned by run() should only be used by the queue.
Source:

hasFailed

Source:

isDone

Source:

isRunning

Source:

isStopped

Source:

name

Source:

name

Source:

observableDone :Observable.<JobEvent>

Type:
Source:

observableFailed :Observable.<JobEvent>

Type:
Source:

observableRun :Observable.<JobEvent>

Type:
Source:

progress

Use this setter to give this Job an instance of Progress that may be used by the scheduler for this Job. This Job itself does not observe the instance or subscribe to its observables.
Source:

progress

Source:

properties

Source:

result

Source:

runDurationMs

Source:

startTime

Source:

stopTime

Source:

supportsProgress

Source:

wasStarted

Source:

Methods

(static) fromProcess(processWrapper) → {Job}

Convenience function to create a Job from a ProcessWrapper. Once run, the Job will run the ProcessWrapper as Observable. All observed output is then reported as Progress, as the Job will be decorated with a Progress-instance of type ProcessOutput.
Parameters:
Name Type Description
processWrapper ProcessWrapper
Source:
Returns:
Type
Job

(static) fromSyncFunction(func) → {Job}

Creates a job from a synchronous function by wrapping it into an async function.
Parameters:
Name Type Description
func function A function that does synchronous work and returns a value (i.e. its result is not awaited).
Source:
Returns:
Type
Job

(async) run() → {Promise.<T>}

Source:
Returns:
the Promise that will resolve with the job's result.
Type
Promise.<T>