https://github.com/patrickjs/promises
Promises/A+ implementation base on http://promises-aplus.github.io/promises-spec/
https://github.com/patrickjs/promises
Last synced: 9 months ago
JSON representation
Promises/A+ implementation base on http://promises-aplus.github.io/promises-spec/
- Host: GitHub
- URL: https://github.com/patrickjs/promises
- Owner: PatrickJS
- Created: 2013-08-22T18:52:49.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-30T13:41:14.000Z (over 12 years ago)
- Last Synced: 2024-10-06T09:21:20.666Z (about 1 year ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Promises
===
[](http://www.youtube.com/watch?v=llDikI2hTtk)
A promise represents a value that may not be available yet. The primary method for interacting with a promise is its .then() method.
###Examples
```javascript
var deferred = Promises();
deferred.then(function(result) {
alert(result);
});
deferred.fulfill('Here is my deferred text');
```
```javascript
var myPromise = (function() {
var defer = Promises();
var randomInterval = ~~(Math.random()*5000);
console.log('randomInterval time set to ' + randomInterval + ' at ' + new Date());
setTimeout(function() {
console.log(new Date());
defer.fulfill('resolved my promise');
}, randomInterval);
return defer;
}());
myPromise.then(function(text) {
alert(text);
});
```