Permalink
Browse files

support for thunks

  • Loading branch information...
1 parent 2d17287 commit 7053aaebbe1b387765296634b3f3a81b37a3044c @jmar777 committed Feb 20, 2014
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/suspend.js
View
@@ -162,12 +162,20 @@ Suspender.prototype.handleYield = function handleYield(ret) {
return;
}
+ // if nothing was yielded, then assume that resume()/join() are being used
+ if (!ret.value) return;
+
// check if a promise was yielded
- if (ret.value && typeof ret.value.then === 'function') {
+ if (typeof ret.value.then === 'function') {
// todo: may be more efficient to have a single instance-level resume
// function
ret.value.then(this.resume.bind(this, null), this.resume.bind(this));
}
+
+ // check if a thunk was yielded
+ if (typeof ret.value === 'function') {
+ ret.value(this.resume.bind(this));
+ }
};
/**

0 comments on commit 7053aae

Please sign in to comment.