Type alias Suspend<T>

Suspend<T>: ((request: Request<T>) => void)

An asynchronous operation that can be waited on by a Job.

When a JobIterator yields a Suspend, the job invokes it with a Request. The Suspend function should arrange for the request to be settled (via resolve or reject).

Note: If the request is not settled, the job will be suspended until cancelled by outside forces. (Such as its enclosing job ending, or explicit throw()/return() calls on the job instance.)

Also note that any subjobs the Suspend function creates (or cleanup callbacks it registers) will not be cleaned up until the calling job ends. So any resources that won't be needed once the job is resumed should be explicitly disposed of -- in which case you should probably just yield * to a start(), instead of yielding a Suspend!

Type Parameters

  • T

Type declaration