Commit d1c0a45d authored by Randall Leeds's avatar Randall Leeds

Simplify the render service

After I changed it so that it took a callback rather than a scope
the data parameter became rather useless.
parent 6c64bd65
......@@ -85,8 +85,8 @@ ThreadController = [
$element.hide()
# Render the view in a future animation frame
render $parse($attrs.thread)($scope), (value) ->
vm.container = value
render ->
vm.container = $parse($attrs.thread)($scope)
$scope.$digest()
$element.show()
......
# The render function accepts a scope and a data object and schedule the scope
# to be updated with the provided data and digested before the next repaint
# using window.requestAnimationFrame() (or a fallback). If the resulting digest
# causes a subsequent invocation of the render function the digest rate is
# effectively limited to ensure a responsive user interface.
# The render service is a function wrapper for scheduling sequential updates
# on window.requestAnimationFrame(). Invoke the function with a callback that
# and the callback will be queued. One callback is handled per animation frame.
# Use this service to schedule DOM-intensive digests.
renderFactory = ['$$rAF', ($$rAF) ->
renderFrame = null
renderQueue = []
render = ->
return renderFrame = null if renderQueue.length is 0
{data, cb} = renderQueue.shift()
do renderQueue.shift()
$$rAF(render)
cb(data)
(data, cb) ->
renderQueue.push {data, cb}
(cb) ->
renderQueue.push cb
renderFrame = $$rAF(render) unless renderFrame
]
......
......@@ -18,7 +18,7 @@ describe 'h.directives.thread', ->
thread: 'thread'
$scope = $rootScope.$new()
flash = sinon.spy()
render = (value, cb) -> cb(value)
render = (cb) -> cb()
createController = ->
$scope.thread = mail.messageContainer()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment