# of

#### signature: `of(...values, scheduler: Scheduler): Observable`

## Emit variable amount of values in a sequence and then emits a complete notification.

### Examples

**Example 1: Emitting a sequence of numbers**

( [StackBlitz](https://stackblitz.com/edit/typescript-kbpvmm?file=index.ts\&devtoolsheight=100) | [jsBin](http://jsbin.com/kodixitoji/1/edit?js,console) | [jsFiddle](https://jsfiddle.net/btroncone/f7b35ayz/) )

```js
// RxJS v6+
import { of } from 'rxjs';
//emits any number of provided values in sequence
const source = of(1, 2, 3, 4, 5);
//output: 1,2,3,4,5
const subscribe = source.subscribe(val => console.log(val));
```

**Example 2: Emitting an object, array, and function**

( [StackBlitz](https://stackblitz.com/edit/typescript-m1jbw9?file=index.ts\&devtoolsheight=100) | [jsBin](http://jsbin.com/xevobujama/1/edit?js,console) | [jsFiddle](https://jsfiddle.net/btroncone/d9rng4dj/) )

```js
// RxJS v6+
import { of } from 'rxjs';
//emits values of any type
const source = of({ name: 'Brian' }, [1, 2, 3], function hello() {
  return 'Hello';
});
//output: {name: 'Brian'}, [1,2,3], function hello() { return 'Hello' }
const subscribe = source.subscribe(val => console.log(val));
```

### Related Recipes

* [Battleship Game](https://www.learnrxjs.io/learn-rxjs/recipes/battleship-game)
* [Breakout Game](https://www.learnrxjs.io/learn-rxjs/recipes/breakout-game)
* [Car Racing Game](https://www.learnrxjs.io/learn-rxjs/recipes/car-racing-game)
* [Mine Sweeper Game](https://www.learnrxjs.io/learn-rxjs/recipes/mine-sweeper-game)
* [Platform Jumper Game](https://www.learnrxjs.io/learn-rxjs/recipes/platform-jumper-game)
* [Save Indicator](https://www.learnrxjs.io/learn-rxjs/recipes/save-indicator)
* [Swipe To Refresh](https://www.learnrxjs.io/learn-rxjs/recipes/swipe-to-refresh)
* [Tetris Game](https://www.learnrxjs.io/learn-rxjs/recipes/tetris-game)
* [Type Ahead](https://www.learnrxjs.io/learn-rxjs/recipes/type-ahead)

### Additional Resources

* [of](https://rxjs.dev/api/index/function/of) 📰 - Official docs
* [Creation operators: of](https://egghead.io/lessons/rxjs-creation-operator-of?course=rxjs-beyond-the-basics-creating-observables-from-scratch) 🎥 💵 - André Staltz

***

> 📁 Source Code: <https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/of.ts>
