Created
June 18, 2014 20:13
-
-
Save twalker/be0fa5f4993984e4e11f to your computer and use it in GitHub Desktop.
Choose a fav confirm style--E, C, or P?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* E */ | |
// Event style (current implementation) | |
var confirm = notifier.confirm('Are you sure?'); | |
this.listenTo(confirm, 'confirm', function(){ | |
// do something | |
}); | |
this.listenTo(confirm, 'cancel', function(){ | |
// recover | |
}); | |
/* C */ | |
// Callback style | |
notifier.confirm('Are you sure?', { | |
confirm: function(){ | |
// do something | |
}, | |
cancel: function(){ | |
// recover | |
} | |
}); | |
/* P */ | |
// Promise style | |
notifier.confirm('Are you sure?').then( | |
function confirmed(){ | |
// do something | |
}, | |
function cancelled(){ | |
// recover | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment