Skip to content

Commit

Permalink
Make warning handlers actually work instead of crash
Browse files Browse the repository at this point in the history
  • Loading branch information
David Goldstein committed Jun 30, 2016
1 parent 051ceee commit 65c4715
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/core/Warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ if (__DEBUG__) {
var argIndex = 0;
var msg = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
console.warn(msg);
warningHandlers.forEach(function(hanlder) {
handler(msg);
});
warningHandlers.call(msg);
}
};
}
Expand Down
7 changes: 7 additions & 0 deletions src/core/WarningHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ function unregister(handler) {
warningHandlers.splice(warningHandlers.indexOf(handler), 1);
}

function callAll(msg) {
warningHandlers.forEach(function(handler) {
handler(msg);
});
}

module.exports = {
register: register,
unregister: unregister,
call: callAll,
}

0 comments on commit 65c4715

Please sign in to comment.