Closed g00fy- closed 10 years ago
There's the background
option in m.request to prevent it from affecting redrawing:
//go ahead and redraw without me
m.request({method: "GET", url: "/foo", background: true})
.then(function() {
//redraw again
m.redraw()
})
@lhorie the background:true
is only m.request
specific - what about other use cases ? 3rd party libs may use jquery for handling http or even IndexedDB which also is async. I think it would be worth implementing a generic solution.
Some components require the DOM
to be already in place. Would it be possible (with the current architecture) to trigger synchronous redraw()
(not with requestAnimationFrame
but at the end of diff computing) ? I know about the config
- but this still is asynchronous.
@g00fy- third party libraries must call m.startComputation
/ m.endComputation
if they want their asynchronous callbacks to be taken into consideration for the redrawing schedule. If not, they can simply call m.redraw
when their completion callbacks run.
Re: synchronous redraws: Does m.redraw(true)
do what you need?
m.render() gets called when all pending computations are resolved,
lets take a case when on user action multiple (2) async computations are called (http call).
1st completes in 200 ms 2nd times out after 30 seconds
the dom would be updated after 30 seconds
The only thing i can think of that would help in this scenario is:
startComputation and endComputation accept config
startComputation(group | timeout);
startComputation returns endComputation callback
example 1 (batch updates)