Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briancavalier/9882393 to your computer and use it in GitHub Desktop.
Save briancavalier/9882393 to your computer and use it in GitHub Desktop.
require('when/monitor/console');
var when = require('when');
// Creates a cycle p1 -> p2 -> p3 -> p4 -> p1
var p1 = when.promise(function(r1) {
var p2 = when.promise(function(r2) {
var p3 = when.promise(function(r3) {
var p4 = when.promise(function(r4) {
setTimeout(function() {
r4(p1); // Cycle! resolve p4 with p1
}, 100);
});
r3(p4);
});
r2(p3);
});
r1(p2);
});
TypeError: Promise cycle
at null._onTimeout (/Users/brian/Projects/cujojs/when/experiments/cycle.js:10:6)
[object Object]
at /Users/brian/Projects/cujojs/when/experiments/cycle.js:8:18
at /Users/brian/Projects/cujojs/when/experiments/cycle.js:7:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment