title: Angular Update instead of replace object
body: <p>I have this code on a service:</p>
  
  <pre><code>private appState = {};
    private state$;
  
    constructor() {
      this.state$ = new BehaviorSubject(this.appState);
    }
  
  setState(key: string, value: any, persist: boolean = false) {
      this.appState[key] = value; // in Memory
      this.state$.next(this.appState); // inform subscribers
      if (persist) {
        if (typeof value === 'object') {
          localStorage[key] = JSON.stringify(value);
        } else {
          localStorage[key] = value;
        }
      }
    }
  </code></pre>
  
  <p>Then on my component:</p>
  
  <p>I first have a method that sets some data:</p>
  
  <pre><code>setCurrentState() {
      this.appStateService.setState('state1', {name: 'Joe Patton', active: true});
  }
  </code></pre>
  
  <p>Then another method where I want to update the above data:</p>
  
  <pre><code>updateCurrentState() {
      this.appStateService.setState('state1', { active: false });
  }
  </code></pre>
  
  <p>My problem is that with the updateCurrentState I want to just update the active field but it's replacing the whole object.</p>
  
  <p>How can I just update the needed data?</p>