> ## Documentation Index
> Fetch the complete documentation index at: https://docs.speckle.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# Loader

> Abstract class that is the base for all concrete loader implementations.

## Constructors

### constructor

```typescript theme={null}
constructor(resource: string, resourceData?: string | ArrayBuffer)
```

Populates the loader with data.

**Parameters**

* **resource**: This can either be a resource URL, either an resource ID
* *(optional)* **resourceData**: Explicit data you want to load

## Accessors

### resource

```typescript theme={null}
get resource(): string
```

Gets the loader's resource.

**Returns**: string

## Methods

### load

```typescript theme={null}
abstract load(): Promise<boolean>
```

This function needs to handle all the resource loading.

**Returns**: A promise which resolves to a boolean indicating if the loading process completed successfully (true) or was interrupted/failed (false)

### cancel

```typescript theme={null}
abstract cancel()
```

This function needs to cancel any ongoing loading process and clean afterwards.

**Returns**: void

### dispose

```typescript theme={null}
abstract dispose()
```

This function needs to dispose of the loader and it's allocated resources.

**Returns**: void

## Typedefs

### LoaderEvent

```typescript theme={null}
enum LoaderEvent {
  LoadProgress = 'load-progress',
  LoadCancelled = 'load-cancelled',
  LoadWarning = 'load-warning'
}
```

The basic events any Loader implementation should use. Implemented and used by both `SpeckleLoader` and `ObjLoader` fully or partially.

### LoaderEventPayload

```typescript theme={null}
interface LoaderEventPayload {
  [LoaderEvent.LoadProgress]: { progress: number; id: string }
  [LoaderEvent.LoadCancelled]: string
  [LoaderEvent.LoadWarning]: { message: string }
}
```

Mapping of loader events to event handler argument types
