# isObservable

> Detect an rxjs Observable at runtime. Useful when writing APIs that should accept either a plain value or a stream and behave accordingly.

Source: https://ngwr.dev/reference/utils/is-observable  
Kind: Util

## Usage

```angular-ts
import { isObservable } from 'ngwr/utils';

if (isObservable(input)) {
  input.subscribe(v => render(v));
} else {
  render(input);
}
```

## Why ngwr provides this

`value instanceof Observable` forces an `import { Observable } from 'rxjs'` into every consumer — even code paths that never actually subscribe. ngwr's duck-typed check (`value && typeof (value as Observable<unknown>).subscribe === 'function'`) stays zero-dep, so a util layer can support both plain values and streams without dragging rxjs in.

```angular-ts
// Native — `instanceof Observable` forces rxjs into the bundle.
import { Observable } from 'rxjs';   // ← pulled into every consumer
if (input instanceof Observable) input.subscribe(render);

// ngwr — duck-typed check. Zero runtime dependency on rxjs.
import { isObservable } from 'ngwr/utils';
if (isObservable(input)) input.subscribe(render);
```

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `isObservable(value)` | Detects an rxjs Observable. Use to write APIs that transparently accept either a plain value or a stream. The element type is a parameter, so `isObservable<Row>(x)` narrows to `Observable<Row>` rather than to `unknown`. | `<T = unknown>(value: unknown) => value is Observable<T>` | `—` |
