<commit_before>import Mixin from '@ember/object/mixin';
import { computed } from '@ember/object';
import { assert } from '@ember/debug';
import WithVisibilityDetection from './with-route-visibility-detection';

export default Mixin.create(WithVisibilityDetection, {
  watchers: computed(() => []),

  cancelAllWatchers() {
    this.watchers.forEach(watcher => {
      assert('Watchers must be Ember Concurrency Tasks.', !!watcher.cancelAll);
      watcher.cancelAll();
    });
  },

  startWatchers() {
    assert('startWatchers needs to be overridden in the Route', false);
  },

  setupController() {
    this.startWatchers(...arguments);
    return this._super(...arguments);
  },

  visibilityHandler() {
    if (document.hidden) {
      this.cancelAllWatchers();
    } else {
      this.startWatchers(this.controller, this.controller.get('model'));
    }
  },

  actions: {
    willTransition() {
      this.cancelAllWatchers();

      // Bubble the action up to the application route
      return true;
    },
  },
});<commit_msg>Don't cancel watchers when transitioning to a sub-route<commit_after>import Mixin from '@ember/object/mixin';
import { computed } from '@ember/object';
import { assert } from '@ember/debug';
import WithVisibilityDetection from './with-route-visibility-detection';

export default Mixin.create(WithVisibilityDetection, {
  watchers: computed(() => []),

  cancelAllWatchers() {
    this.watchers.forEach(watcher => {
      assert('Watchers must be Ember Concurrency Tasks.', !!watcher.cancelAll);
      watcher.cancelAll();
    });
  },

  startWatchers() {
    assert('startWatchers needs to be overridden in the Route', false);
  },

  setupController() {
    this.startWatchers(...arguments);
    return this._super(...arguments);
  },

  visibilityHandler() {
    if (document.hidden) {
      this.cancelAllWatchers();
    } else {
      this.startWatchers(this.controller, this.controller.get('model'));
    }
  },

  actions: {
    willTransition(transition) {
      // Don't cancel watchers if transitioning into a sub-route
      if (!transition.intent.name.startsWith(this.routeName)) {
        this.cancelAllWatchers();
      }

      // Bubble the action up to the application route
      return true;
    },
  },
});
{'fraction_non_alphanumeric': 0.14007954043305346, 'fraction_numerical': 0.0, 'mean_word_length': 3.3622350674373798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6320650', 'n_tokens_mistral': 669, 'n_tokens_neox': 649, 'n_words': 147}