Comments (2)
谢谢你的反馈,最近比较忙,没看到,我会尽快排查。
from easyjs.
@acelan86 你上面的Demo代码在使用上有点问题,easy.js 的 promise 设计的 E.when 方法只接受 promise 实例的参数,而你的 Demo 代码中传递给 when 方法的并不是 promise 实例。then 方法返回的并不是一个 promise 实例,then 方法返回的 this 是为了便于链式调用,这种错误的使用方法导致的 pmeCahce 中的列表被清除就不足为奇了。
正确的使用方法应该是这样的:
var showMsg1 = function(){
var promise = new E.Promise();
setTimeout(function(){
alert( 'ok1' );
promise.resolve( 'hello1' );
}, 2000 );
return promise;
};
var showMsg2 = function(){
var promise = new E.Promise();
setTimeout(function(){
alert( 'ok2' );
promise.resolve( 'hello2' );
}, 8000 );
return promise;
};
E.when( showMsg1(), showMsg2() ).then(function( str1, str2 ){
alert( str1 + ' ' + str2 );
}).then(function(){
alert( 'all promise is done' );
});
from easyjs.
Related Issues (3)
- 几点建议 HOT 1
- dialog BUG HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyjs.