Angular: Using BehaviorSubject to react to a user action

Recently I had a case where I needed some Angular components to listen to a user action and update their model based on that action.

That action was switching languages for specific components. There are many ways to actually achieve such a behavior, but I decided that the most elegant way was to use BehaviorSubject.

(more…)