---
url: >-
  https://lit-ui-router.dev/reference/ui-router-signals/functions/watchSelection.md
---
[ui-router-signals](../index.md) / watchSelection

# Function: watchSelection()

```ts
function watchSelection<T>(
   expression, 
   equals, 
   apply
): () => void;
```

Defined in: [ui-router-signals/src/watch.ts:10](https://github.com/simshanith/lit-ui-router/blob/740888c2b2ba358c4dfa52a122e927df6a604b12/packages/ui-router-signals/src/watch.ts#L10)

Watches `expression` through a `Signal.Computed` and hands every new value
to `apply`: once synchronously, then in a microtask after any source
changes. A value the computed's `equals` judges unchanged is skipped.

## Type Parameters

| Type Parameter |
| ------ |
|  `T` |

## Parameters

| Parameter | Type |
| ------ | ------ |
| `expression` | () => `T` |
| `equals` | ((`a`, `b`) => `boolean`) | `undefined` |
| `apply` | (`value`) => `void` |

## Returns

a function that stops watching.

() => `void`
