# BindingBase

Class · extends `Events`

Source: https://github.com/playcanvas/pcui/blob/77ed2b8ba8660c9644049b0d1942652721e7a6c4/src/binding/BindingBase/index.ts#L40

Base class for data binding between [IBindable](https://api.playcanvas.com/pcui/interfaces/IBindable.md) [Element](https://developer.mozilla.org/docs/Web/API/Element)s and Observers.

## Constructors

### constructor

```ts
new BindingBase(args: Readonly<BindingBaseArgs>)
```

Creates a new binding.

**Parameters**

- `args` (`Readonly<`[`BindingBaseArgs`](https://api.playcanvas.com/pcui/interfaces/BindingBaseArgs.md)`>`): The arguments.

## Accessors

### applyingChange

```ts
get applyingChange(): boolean
set applyingChange(value: boolean)
```

Gets whether the binding is currently applying a change, either to the observers or the element.

### element

```ts
get element(): IBindable<unknown>
set element(value: IBindable<unknown>)
```

Gets the element.

### historyCombine

```ts
get historyCombine(): boolean
set historyCombine(value: boolean)
```

Gets whether to combine history actions when applying changes to observers.

### historyEnabled

```ts
get historyEnabled(): boolean
set historyEnabled(value: boolean)
```

Gets whether history is enabled for the binding.

### historyName

```ts
get historyName(): string
set historyName(value: string)
```

Gets the name of the history action when applying changes to observers.

### historyPostfix

```ts
get historyPostfix(): string
set historyPostfix(value: string)
```

Gets the string to postfix [historyName](https://api.playcanvas.com/pcui/classes/BindingBase.md#historyname) with.

### historyPrefix

```ts
get historyPrefix(): string
set historyPrefix(value: string)
```

Gets the string to prefix [historyName](https://api.playcanvas.com/pcui/classes/BindingBase.md#historyname) with.

### linked

```ts
get linked(): boolean
```

Gets whether the binding is linked to observers.

### observers

```ts
get observers(): Observer[]
```

Gets the linked observers.

### paths

```ts
get paths(): string[]
```

Gets the linked paths.

## Methods

### addValue

```ts
addValue(value: unknown): void
```

Adds (inserts) a value to the linked observers at the linked paths.

**Parameters**

- `value` (`unknown`): The value.

### addValues

```ts
addValues(values: unknown[]): void
```

Adds (inserts) multiple values to the linked observers at the linked paths.

**Parameters**

- `values` (`unknown[]`): The values.

### clone

```ts
clone(): BindingBase
```

Clones the binding. To be implemented by derived classes.

**Returns** [`BindingBase`](https://api.playcanvas.com/pcui/classes/BindingBase.md)

### link

```ts
link(observers: Observer | Observer[], paths: string | string[]): void
```

Links the specified observers to the specified paths.

**Parameters**

- `observers` (`Observer | Observer[]`): The observer(s).
- `paths` (`string | string[]`): The path(s). The behavior of the binding depends on how many paths are passed.
  If an equal amount of paths and observers are passed then the binding will map each path to each observer at each index.
  If more observers than paths are passed then the path at index 0 will be used for all observers.
  If one observer and multiple paths are passed then all of the paths will be used for the observer (e.g. for curves).

### removeValue

```ts
removeValue(value: unknown): void
```

Removes a value from the linked observers at the linked paths.

**Parameters**

- `value` (`unknown`): The value.

### removeValues

```ts
removeValues(values: unknown[]): void
```

Removes multiple values from the linked observers from the linked paths.

**Parameters**

- `values` (`unknown[]`): The values.

### setValue

```ts
setValue(value: unknown): void
```

Sets a value to the linked observers at the linked paths.

**Parameters**

- `value` (`unknown`): The value

### setValues

```ts
setValues(values: unknown[]): void
```

Sets an array of values to the linked observers at the linked paths.

**Parameters**

- `values` (`unknown[]`): The values.

### unlink

```ts
unlink(): void
```

Unlinks the observers and paths.
