# Function: toSource()

> **toSource**\<`Payload`, `Type`\>(`type`): (`source$`) => `Observable`\<[`Action`](../../../state-adapt-core/references/src/Action.md)\<`Payload`, `Type`\>\>

`toSource` is a custom RxJS [operator](https://rxjs.dev/guide/operators) that converts an RxJS [Observable](https://rxjs.dev/guide/observable)
of values of type Payload (inferred) into an observable of values of type [Action](../../../state-adapt-core/references/src/Action.md)<Payload, Type>.
It takes one argument, `type`, which is the `type` property of the [Action](../../../state-adapt-core/references/src/Action.md) objects that will be emitted, and which will
appear as the action type in Redux DevTools:

![Action Type in Redux Devtools](https://state-adapt.github.io/assets/devtools-timer$.png)

#### Example: Converting an observable into a source

```typescript
import { timer } from 'rxjs';
import { toSource } from '@state-adapt/rxjs';

const timer$ = timer(1000).pipe(toSource('timer$'));

timer$.subscribe(console.log);
// { type: 'timer$', payload: 0 }
```
