> For the complete documentation index, see [llms.txt](https://docs.aurelia.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aurelia.io/getting-to-know-aurelia/state-and-observation/observation/observing-property-changes-with-observable.md).

# Observing property changes with @observable

Unlike the [@watch decorator](/getting-to-know-aurelia/state-and-observation/watching-data.md), the `@observable` decorator allows you to decorate properties in a component and optionally call a change callback when the value changes. It works quite similarly to the `@bindable` property.

By convention, the change handler is a method whose name is composed of the property\_name and the literal value 'Changed'. For example, if you decorate the property `color` with `@observable`, you have to define a method named `colorChanged()` to be the change handler.

This is what a basic observable would look like using conventions:

```typescript
import { observable } from 'aurelia';

export class Car {
  @observable color = 'blue';

  colorChanged(newValue, oldValue) {
    // this will fire whenever the 'color' property changes
  }
}
```

When the `color` value is changed, the `colorChanged` callback will be fired. The new changed value will be the first argument, and the existing one will be the second one.

If you prefer, you can also put the `@observable` decorator on classes:

```typescript
import { observable } from 'aurelia';

@observable('color')
@observable({ name: 'speed', callback: 'speedCallback' })
export class Car {
  color = 'blue';
  speed = 300;

  colorChanged(newValue, oldValue) {
    // this will fire whenever the 'color' property changes
  }

  speedCallback(newValue, oldValue) {
    // this will fire whenever the 'speed' property changes
  }
}
```

{% hint style="info" %}
You do not have to check if `newValue` and `oldValue` are different. The change handler will not be called if you assign a value the property already has.
{% endhint %}

## Specifying a different change callback

If you do not want to use the convention, you can define the callback name for the change handler by setting the `callback` property of the `@observable` decorator:

```typescript
import { observable } from 'aurelia';

export class Car {
  @observable({ callback: 'myCallback' }) color = 'blue';

  myCallback(newValue, oldValue) {
    // this will fire whenever the 'color' property changes
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.aurelia.io/getting-to-know-aurelia/state-and-observation/observation/observing-property-changes-with-observable.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
