catch y-* related errors

This commit is contained in:
Kevin Jahns
2017-09-20 11:29:13 +02:00
parent f537a43e29
commit 40fb16ef32
2 changed files with 12 additions and 5 deletions

View File

@@ -67,7 +67,11 @@ export default function Utils (Y) {
this._eventListener[name] = listener.filter(e => e !== f)
}
emit (name, value) {
(this._eventListener[name] || []).forEach(l => l(value))
let listener = this._eventListener[name] || []
if (name === 'error' && listener.length === 0) {
console.error(value)
}
listener.forEach(l => l(value))
}
destroy () {
this._eventListener = null