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

Fixing setTimeout so it passes extra parameters through to the callback function #82

Closed ccummings closed 8 years ago

ccummings commented 8 years ago

can-zone's setTimeout only passes the callback and delay to window.setTimeout here.

setTimeout can be passed parameters that should be passed through to the callback.

This PR makes sure all arguments are passed to setTimeout; making sure the first argument is the waitsFor function can-zone creates.

Example

var Zone = require("can-zone");

var zone = new Zone();

zone.run(function(){

  setTimeout(function(str1, str2){
        zone.data.foo = str1 + "-" + str2; //-> undefined-undefined
    }, 100, "can-zone", "canjs")

}).then(function(data){
  console.log(data.foo);
});
matthewp commented 8 years ago

Thanks!

matthewp commented 8 years ago

Published as 0.5.7.