1cca7abcab
This is extracted from #8094, where I have run into some snags. Since these ESLint fixes aren’t actually connected to the Ember 3.16 update but involve changes to many files, we might as well address them separately. Where possible I fixed the problems but in cases where a fix seemed too involved, I added per-line or -file exceptions.
25 lines
756 B
JavaScript
25 lines
756 B
JavaScript
import Ember from 'ember';
|
|
import Mixin from '@ember/object/mixin';
|
|
import { assert } from '@ember/debug';
|
|
import { on } from '@ember/object/evented';
|
|
|
|
// eslint-disable-next-line ember/no-new-mixins
|
|
export default Mixin.create({
|
|
visibilityHandler() {
|
|
assert('visibilityHandler needs to be overridden in the Component', false);
|
|
},
|
|
|
|
setupDocumentVisibility: on('init', function() {
|
|
if (!Ember.testing) {
|
|
this.set('_visibilityHandler', this.visibilityHandler.bind(this));
|
|
document.addEventListener('visibilitychange', this._visibilityHandler);
|
|
}
|
|
}),
|
|
|
|
removeDocumentVisibility: on('init', function() {
|
|
if (!Ember.testing) {
|
|
document.removeEventListener('visibilitychange', this._visibilityHandler);
|
|
}
|
|
}),
|
|
});
|