mithril-vndb/api/autoredraw.js
impinball b4fb21475c Add editorconfig, resolve differences
This includes newlines, tabs, among other things.
2016-06-18 03:22:12 -04:00

19 lines
388 B
JavaScript

"use strict"
var throttle = require("../api/throttle")
module.exports = function(root, renderer, pubsub, callback) {
var run = throttle(callback)
if (renderer != null) {
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
}