# Jobs

Class · extends `Events` · category: Internal

Source: https://github.com/playcanvas/editor-api/blob/4303c34bcee9a418297350899ad3a3f555526ec4/src/jobs.ts#L10

Facilitates tracking of asynchronous jobs.

## Methods

### finish

```ts
finish(jobId: string): Function
```

Notifies that a job has finished. The specified job
id is removed and the callback stored when the job was
started is returned.

**Parameters**

- `jobId` (`string`): The job id

**Returns** `Function`: The function stored when the job was started

**Example**

```javascript
const jobId = editor.jobs.start(() => console.log('job was finished'));
editor.jobs.finish(jobId)(); // prints 'job was finished'
```

### start

```ts
start(fn: Function): string
```

Adds a new job. The specified function will be returned when the
job is finished.

**Parameters**

- `fn` (`Function`): A function to be stored for this job.

**Returns** `string`: Returns a job id

**Example**

```javascript
const jobId = editor.jobs.start(() => console.log('job was finished'));
editor.jobs.finish(jobId)(); // prints 'job was finished'
```

## Inherited from Events

- `new Jobs()`
