从蓝鸟中绑定方法可以在呼叫之间保存上下文(这)



此文档http://bluebirdjs.com/docs/api/promise.bind.html我期待偏见的环境的生活将以呼叫的结束结束。但显然不是。
以下代码:

const Promise = require('bluebird');
const chain = (callNumber) => {
    console.log('call:', callNumber, '============');
    return asyncFunction()
        .bind({})
        .then(() => {
            console.log('this', callNumber, this);
            this.t = 1
        })
        .then(() => {
            this.t2 = 2
        })
        .then(() => {
            console.log('this', callNumber, this);
        })
};
const asyncFunction = () => new Promise((resolve) => {
    return Promise.delay(100)
        .then(resolve);
});
chain(1).then(() => chain(2));

产生此结果:

call: 1 ============
this 1 {}
this 1 { t: 1, t2: 2 }
call: 2 ============
this 2 { t: 1, t2: 2 }
this 2 { t: 1, t2: 2 }

预期结果:

call: 1 ============
this 1 {}
this 1 { t: 1, t2: 2 }
call: 2 ============
this 2 {}
this 2 { t: 1, t2: 2 }

这是正确的行为还是我在某个地方犯了错误?

蓝鸟Promise.bind被滥用。它应该与动态this一起使用:

没有提供词汇的箭头功能,在编写面向对象的代码时,异步和同步代码之间的对应关系会分解。。

例如:

promise.bind({})
.then(function () {
    console.log('this', callNumber, this);
    this.t = 1
})

使用箭头功能,this是词汇,是指节点模块module.exports。在chain调用之间保持相同。