Operators - construction

create

When you are starting out or you just want to test something you tend to start out with the create() operator. This takes a function with an observer as a parameter. This has been mentioned in previous sections such as Observable Wrapping. The siignature looks like the following

Observable.create([fn])
1

And an example looks like:

import { Observable } from 'rxjs';

Observable.create(observer => {
  observer.next( 1 );
})
1
2
3
4
5

range

Signature

import { range } from 'rxjs';

range([start],[count])
1
2
3

Example

import { range } from 'rxjs';

let stream$ = range(1,3)

// emits 1,2,3
1
2
3
4
5