Closed matthewp closed 8 years ago
Having trouble deciding on the API. Here's a rough cut of how it would be used for server-side rendering with an explanation:
var zone = new Zone({
plugins: [require("can-zone/timeout")]
});
var timeoutPromise = zone.timeout(5000);
var runPromise = zone.run(function(){
render()
});
Promise.race([
timeoutPromise,
runPromise
]).then(function(){
res.send(doc.innerHTML);
});
runPromise.then(function(){
cleanup();
});
The reason we need both promises is because we need to do cleanup after the runPromise has completed, even if it takes longer than the timeout.
This is a plugin that will provide timeout capabilities.