canjs / can-zone

A context for tracking asynchronous activity in JavaScript applications.
https://v4.canjs.com/doc/can-zone.html
MIT License
92 stars 4 forks source link

Implement can-zone/timeout #72

Closed matthewp closed 8 years ago

matthewp commented 8 years ago

This adds can-zone/timeout a plugin to create timeouts for when a Zone should be completed.

You use it like:

var timeout = require("can-zone/timeout");
var TimeoutError = timeout.TimeoutError;

var zone = new Zone({
    plugins: [timeout(5000)]
});

zone.run(function(){
    setTimeout(function(){}, 10000);
}).catch(function(err){

    // err instanceof TimeoutError

});
matthewp commented 8 years ago

This needs docs.

matthewp commented 8 years ago

To document: