Comments (9)
串行不是一路then
就行了吗?
a.then(b).then(c).then(d).fail(handleError);
from er.
这样在回调中写下一个请求,要是多有几个,会感觉到嵌套过深
from er.
能不能看看你们现在的代码会是怎么样子的……我感觉这2个代码:
fetchData()
.then(processData)
.then(generateTableContent)
.then(displayTable);
Deferred.series(
fetchData,
processData,
generateTableContent,
displayTable
);
连缩进数量都是一样的……
from er.
额···估计我表述没太清楚,
是下面这种情况
fetchData() .then(function () { //Todo fetchData2().then(function() { //Todo fetchData3().then ... }); })
我理解的串行加载是这样的,一个ajax接着一个ajax
from er.
不是应该这么写吗:
fetchData()
.then(fetchData2)
.then(fetchData3)
.then ...
效果是一样的,你这么写就是没用好Promise吧……
from er.
fetchData() .then(fetchData2) .then(fetchData3) .then ...
这种写法我以为fetchData2、fetchData3是平级的,他们之间没有先后关系,不存在依赖··· 不知道是不是我理解then错了···汗
from er.
所谓then,就是一件事做好then做另一件事嘛,英语啊英语……然后then会把上一个callback的return值送到下一个callback作为参数,所以fetchData2
会收到fetchData
得到的数据,下面也一样
from er.
嗯 只要fetchData3能得到fetchData2的数据就好了··· 看来then确实我没理解透彻,我以为then是把handler都放到一个数组中,然后循环一把都执行了···汗···
from er.
最终问题是在then中忘记return了~~~巨汗~~
from er.
Related Issues (20)
- 子Action中a标签外跳到一个er path的需求 HOT 7
- [template]etpl2/3从Model中取值问题 HOT 2
- controller#forward,mix options给actionContext会出问题 HOT 2
- 两层以上的ChildAction里发生global redirect的时候会报错 HOT 6
- 页面切换次数多了的时候,会出现hash跳转了但是view没渲染的情况 HOT 24
- 开放路径访问权限方法 HOT 1
- enteractionfail事件增加参数
- ER 不在npmjs.org 里? HOT 4
- ER的两点疑问 HOT 11
- er/controller forwardaction 并不能阻止后续load行为 HOT 1
- 老ER里refresh 为啥只刷新控件,而不重载render整个 tpl HOT 1
- locator中updateURL函数为啥还要比较一次getLocation() !== url HOT 1
- er在ie6,7,8里哪些功能不能用? HOT 2
- 有什么地方可以设置所有的action在complete的时候执行同一个方法么? HOT 2
- [email protected] 与 [email protected] 兼容问题 HOT 3
- Model 中复制 datasource 有 bug
- er的默认路径可以默认不显示吗?
- events.js中有几个event的说明重复有误
- 貌似这里promise resolver里this指向全局,并没有绑定当前context是promise
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 er.