# Class LayerApi<P, LayerDataTransferObject>

Manages a set of layers (Layer) of a specified format. Layers can be added and unloaded.

#### Type Parameters

- P extends MergableObject<P>
- LayerDataTransferObject

##### Index

### Constructors

constructor

### Properties

layerFormat

### Methods

getOrLoadLayer
unload

## Constructors

### constructor

- new LayerApi<P extends MergableObject<P>, LayerDataTransferObject>(
  _api: BimApi,
  layerFormat: string,
  _serialize: Serialize<LayerDataTransferObject, P, LayerInterface<P>>,
  ): LayerApi<P, LayerDataTransferObject>

  #### Type Parameters

  - P extends MergableObject<P>
  - LayerDataTransferObject

  #### Parameters

  - _api: BimApi

    API instance to use

  - layerFormat: string

    Type of layer. For example "sensor"

  - _serialize: Serialize<LayerDataTransferObject, P, LayerInterface<P>>

    Methods to convert between layer objects (implements MergableObject) and their DTO's (data transferable object). DTO's are what is actually stored in the layers (think of it as serialized layer objects).

  #### Returns LayerApi<P, LayerDataTransferObject>

## Properties

### `Readonly` layerFormat

layerFormat: string

Type of layer. For example "sensor"

## Methods

### getOrLoadLayer

- getOrLoadLayer<Change extends LayerCompatibleChange>(
  change: Change,
  ): Promise<LayerFailure | Layer<Change, P, LayerDataTransferObject>>

  Get a layer for a specified change

  #### Type Parameters

  - Change extends LayerCompatibleChange

  #### Parameters

  - change: Change

    Change to get layer for.

  #### Returns Promise<LayerFailure | Layer<Change, P, LayerDataTransferObject>>

  Either the Layer or a LayerFailure. Use isFailure to check if the return value is a fLayerFailure or a Layer.

### unload

- unload(change: string | Pick<LayerCompatibleChange, "id">): boolean

  Unloads layer of type layerFormat from specified change

  #### Parameters

  - change: string | Pick<LayerCompatibleChange, "id">

    Change to unload layer for.

  #### Returns boolean

  `true` if layer was unloaded. `false` if layer did not exist in LayerApi.