Permalink
Browse files

updated example for wrap/unwrap, seems to work

  • Loading branch information...
1 parent b04a26e commit fb890b57d843dd8dafd1fae48d51b45e199afcd2 @substack committed Jun 20, 2012
Showing with 12 additions and 10 deletions.
  1. +11 −9 example/weak.js
  2. +1 −1 index.js
View
@@ -9,15 +9,17 @@ var s = (function () {
},
y : 555
};
- return proto(cons, function (cb, id) {
- var ref = weak(cb, function () {
- console.log('s.cull(' + id + ')')
- s.cull(id);
- });
- return function () {
- var f = weak.get(ref);
- if (f) f.apply(this, arguments);
- };
+ return proto(cons, {
+ wrap : function (cb, id) {
+ return weak(cb, function () {
+ console.log('s.cull(' + id + ')')
+ s.cull(id);
+ });
+ },
+ unwrap : function (ref, id) {
+ var cb = weak.get(ref);
+ return cb || function () {};
+ }
});
})();
View
@@ -68,7 +68,7 @@ Proto.prototype.handle = function (req) {
return cb;
}
return self.unwrap
- ? self.unwrap(self.callbacks.remote[id])
+ ? self.unwrap(self.callbacks.remote[id], id)
: self.callbacks.remote[id]
;
});

0 comments on commit fb890b5

Please sign in to comment.