我有一个像这样的函数,使用Promises
和NodeJS v6.10
:
function doSomeAsyncThings() {
return this.doAsync().then((res) => {
return this.logAsync().then(() => res)
});
};
现在在上面的例子的背景下,this.logAsync()
对我的应用程序并不重要,但更多用于记录保存目的。出于这个原因,我想知道我是否可以在后台执行此操作,因此没有等待或完成返回res
?
function doSomeAsyncThings() {
return this.doAsync().then(value => {
this.logAsync()
// do things with your `value`
});
};
只是不要等待它。