Created
November 14, 2011 07:54
-
-
Save clauswitt/1363479 to your computer and use it in GitHub Desktop.
SimplePromise Test File
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
| 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