refactor redraw into pubsub and autoredraw
- pubsub is a basic pubsub impl - autoredraw is glue code to register callback to pubsub and onevent moved e.redraw to autoredraw
This commit is contained in:
parent
db46bb4414
commit
0005cf26ee
13 changed files with 149 additions and 105 deletions
|
|
@ -1,55 +0,0 @@
|
|||
"use strict"
|
||||
|
||||
var o = require("../../ospec/ospec")
|
||||
var createRedraw = require("../../api/redraw")
|
||||
|
||||
o.spec("m.redraw", function() {
|
||||
var redraw, renderers
|
||||
|
||||
o.beforeEach(function() {
|
||||
renderers = []
|
||||
redraw = createRedraw(renderers)
|
||||
})
|
||||
|
||||
o("it shouldn't error if there are no renderers", function() {
|
||||
redraw()
|
||||
})
|
||||
|
||||
o("it should run a single renderer entry", function() {
|
||||
var spy = o.spy()
|
||||
|
||||
renderers.push(spy)
|
||||
|
||||
redraw()
|
||||
|
||||
o(spy.callCount).equals(1)
|
||||
|
||||
redraw()
|
||||
redraw()
|
||||
redraw()
|
||||
|
||||
o(spy.callCount).equals(4)
|
||||
})
|
||||
|
||||
o("it should run all renderer entries", function() {
|
||||
var spy1 = o.spy()
|
||||
var spy2 = o.spy()
|
||||
var spy3 = o.spy()
|
||||
|
||||
renderers.push(spy1, spy2, spy3)
|
||||
|
||||
redraw()
|
||||
|
||||
o(spy1.callCount).equals(1)
|
||||
o(spy2.callCount).equals(1)
|
||||
o(spy3.callCount).equals(1)
|
||||
|
||||
redraw()
|
||||
redraw()
|
||||
redraw()
|
||||
|
||||
o(spy1.callCount).equals(4)
|
||||
o(spy2.callCount).equals(4)
|
||||
o(spy3.callCount).equals(4)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue