code: def _on_state_changed(self):
          
          raw_state, generation = self.state.raw_state_and_generation
          if generation != self._last_generation:
              self._last_generation = generation
              self._send_update(raw_state, generation)
docs: Invoked when the viewer state changes.