Skip to content

Instantly share code, notes, and snippets.

@tobie
Created September 11, 2010 12:56
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 tobie/575161 to your computer and use it in GitHub Desktop.
Save tobie/575161 to your computer and use it in GitHub Desktop.
var template = 'Hello, {{ name }}!';
function speak(name) {
console.log(template.replace('{{ name }}', name));
}
function getName() {
if (Math.random() > 0.5) {
var deffered = new dojo.Deferred();
setTimeout(function() { deffered.callback('World'); }, 10);
return deffered;
} else {
return 'World';
}
}
dojo.when(getName(), speak);
template = 'Bye, {{ name }}!';
dojo.when(getName(), speak);
// What's the expected output?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment