Producer

A producer have the task of producing the values emitted by an Observable

  1. class Producer {
  2. constructor(){
  3. this.i = 0;
  4. }
  5. nextValue(){
  6. return i++;
  7. }
  8. }

And to use it

  1. let stream$ = Rx.Observable.create( (observer) => {
  2. observer.next( Producer.nextValue() )
  3. observer.next( Producer.nextValue() )
  4. })

In the Observable Anatomy chapter there is no Producer in the examples but most Observables that are created by a helper method will have an internal Producer producing values that the observer emits using the observer.next method