mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
update plugin promise docs
This commit is contained in:
parent
e8b34920af
commit
1bbdec33e7
19
README.md
19
README.md
@ -392,16 +392,19 @@ js/css.js:
|
||||
```javascript
|
||||
exports.fetch = function(load) {
|
||||
// return a thenable for fetching (as per specification)
|
||||
return new Promise(function(resolve, reject) {
|
||||
var cssFile = load.address;
|
||||
// alternatively return new Promise(function(resolve, reject))
|
||||
return {
|
||||
then: function(resolve, reject) {
|
||||
var cssFile = load.address;
|
||||
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = cssFile;
|
||||
link.onload = resolve;
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = cssFile;
|
||||
link.onload = resolve;
|
||||
|
||||
document.head.appendChild(link);
|
||||
});
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
exports.locate = function(load) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
resolve('custom fetch');
|
||||
}, 20);
|
||||
});
|
||||
return {
|
||||
then: function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
resolve('custom fetch');
|
||||
}, 20);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.fetch = function(load) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
resolve(load.address);
|
||||
}, 20);
|
||||
});
|
||||
return {
|
||||
then: function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
resolve(load.address);
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.translate = function(load) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user