---
url: /api/formats/scope/src/functions/observeScope.md
---
[pantoken-root](../../../../index.md) / [formats/scope/src](../index.md) / observeScope

# Function: observeScope()

> **observeScope**(`target`, `listener`): () => `void`

Beta

Call `listener` whenever the scope resolved for `target` changes, including when an ancestor's
attributes change.

## Parameters

### target

`Element`

### listener

(`scope`) => `void`

## Returns

A stop function.

() => `void`

## Example

```ts
import { observeScope } from "@pantoken/scope";

const stop = observeScope(el, (scope) => render(scope.theme, scope.scheme));
```
