Skip to content

Instantly share code, notes, and snippets.

@dominykas
Created October 23, 2012 00:39
Show Gist options
  • Save dominykas/3935913 to your computer and use it in GitHub Desktop.
Save dominykas/3935913 to your computer and use it in GitHub Desktop.
What should the order be?
var Q = require("q");
var promise = Q.resolve("ok");
promise
.then(function(v){
console.log("then1");
})
.fin(function(){
console.log("fin1");
})
.end();
promise
.then(function(v){
console.log("then2");
})
.then(function(v){
console.log("then2.1");
})
.fin(function(){
console.log("fin2.1");
})
.then(function(){
console.log("then2.2");
})
.fin(function(){
console.log("fin2.3");
})
.end();
promise
.then(function(){
console.log("then3");
})
.fin(function(){
console.log("fin3");
})
.end();
then1
then2
then3
fin1
then2.1
fin3
fin2.1
then2.2
fin2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment