> For the complete documentation index, see [llms.txt](https://sryvkver.gitbook.io/cobi.bike/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sryvkver.gitbook.io/cobi.bike/namespaces/motor/distance.md).

# Distance

Defines the total traveled distance by the system in km.

{% tabs %}
{% tab title="Typescript" %}

```typescript
const onDistanceChange = (value: number, timestamp?: Date) => {
    console.log(value, timestamp);
};

COBI.motor.distance.read(onDistanceChange); // Instantly get the current value
COBI.motor.distance.subscribe(onDistanceChange);
COBI.motor.distance.unsubscribe(onDistanceChange);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const onDistanceChange = (value: number, timestamp?: Date) => {
    console.log(value, timestamp);
};

COBI.motor.distance.read(onDistanceChange); // Instantly get the current value
COBI.motor.distance.subscribe(onDistanceChange);
COBI.motor.distance.unsubscribe(onDistanceChange);
```

{% endtab %}
{% endtabs %}
