Question · Angular course · Module 7: RxJS

asObservable in a state service

Why, in a state service, do we expose the stream through this.subject.asObservable()?

Answer options

  • To speed up value emission
  • So that next() cannot be called and values cannot be emitted from the outside
  • To automatically cancel subscriptions
  • To convert a Subject into a BehaviorSubject

You can check the correct answer by solving this task in the CodeWorlds game.