make renderer optional in autoredraw module

This commit is contained in:
Leo Horie 2016-05-21 01:14:59 -04:00
parent 9b602edf4e
commit 6400b616fc

View file

@ -4,9 +4,11 @@ var throttle = require("../api/throttle")
module.exports = function(root, renderer, pubsub, callback) {
var run = throttle(callback)
renderer.setEventCallback(function(e) {
if (e.redraw !== false) run()
})
if (renderer != null) {
renderer.setEventCallback(function(e) {
if (e.redraw !== false) run()
})
}
if (pubsub != null) {
if (root.redraw) pubsub.unsubscribe(root.redraw)