Skip to content

Instantly share code, notes, and snippets.

@clauswitt
Created November 14, 2011 07:54
Show Gist options
  • Select an option

  • Save clauswitt/1363479 to your computer and use it in GitHub Desktop.

Select an option

Save clauswitt/1363479 to your computer and use it in GitHub Desktop.
SimplePromise Test File
require(['SimplePromise'], function(SimplePromise) {
var p = SimplePromise();
p.promise(function(sleepTime) {
//This function is called by the run call at the end of this file.
var alarm, now = new Date();
var startingMSeconds = now.getTime();
var sleeping = true;
while(sleeping){
alarm = new Date();
alarmMSeconds = alarm.getTime();
if(alarmMSeconds - startingMSeconds > sleepTime){ sleeping = false; }
}
return 'test complete';
}).then(function(response){
//This function is called when the promise-function returns.
alert(response);
}).run(1000);
});
alert('Test began');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment