YulePale
YulePale

Reputation: 7666

what is the difference between observer and subscriber in RXJS?

What is the difference between observer and subscriber in RXJS?

See the code below

// subscriber being used
const observable = new Observable(subscriber => {
  subscriber.next(1);
  subscriber.next(2);
})

// observer being used
const observable = new Observable(observer => {
  observer.next(1);
  observer.next(2);
})

What is the difference between observer and subscriber in the context above?

Upvotes: 0

Views: 262

Answers (1)

Steve Holgado
Steve Holgado

Reputation: 12071

These are the same. In this case, subscriber or observer is just the name given to the function parameter. You could call it anythingYouWant and it would function the same:

const observable = new Observable(anythingYouWant => {
  anythingYouWant.next(1);
  anythingYouWant.next(2);
})

Upvotes: 5

Related Questions