让构造函数返回承诺是不好的做法吗?
new
var engine = new Engine({path: '/path/to/posts'}).then(function (eng) { // allow user to interact with the newly created engine object inside 'then' engine.showPostsOnOnePage();});
var engine = new Engine({path: '/path/to/posts'});// ERROR// engine will not be available as an Engine object here
这可能会造成问题,因为用户可能会混淆为什么 engine
施工后不可用。
new
.
engine.start().then()
engine.init()
慕尼黑的夜晚无繁华
守着一只汪
相关分类