Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
add(...values) {
// until https://github.com/eslint/eslint/issues/12117 is resolved:
// eslint-disable-next-line no-unused-vars
for (let val of values) {
if (!Disposable.isDisposable(val)) {
if (typeof val === "function") {
val = new Disposable(val);
} else {
console.error(
`val is of type ${typeof val}, was expected to be disposable or a function`
);
}
}
super.add(val);
}
}
}
_makeDisposable(o) {
if (Disposable.isDisposable(o)) return o;
if (typeof o === 'function') {
return new Disposable(o);
} else {
throw new Error('must be a function');
}
}
atom.workspace.observeTextEditors(editor => {
let sub
editor.element.addEventListener('mousedown', onMouseDown, true)
const removeListener = () => editor.element.removeEventListener('mousedown', onMouseDown, true)
this.subscriptions.add((sub = new Disposable(removeListener)))
editor.onDidDestroy(() => this.subscriptions.remove(sub))
})
)
subscribe(eventName, handler){
return this.emitter
? this.emitter.on(eventName, handler)
: new Disposable(() => {});
}