- pubsub is a basic pubsub impl - autoredraw is glue code to register callback to pubsub and onevent moved e.redraw to autoredraw
17 lines
No EOL
358 B
JavaScript
17 lines
No EOL
358 B
JavaScript
"use strict"
|
|
|
|
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 (pubsub != null) {
|
|
if (root.redraw) pubsub.unsubscribe(root.redraw)
|
|
pubsub.subscribe(run)
|
|
}
|
|
|
|
return root.redraw = run
|
|
} |