를 해결 한 후 슈퍼 액션을 호출하고 내 하위 클래스에서 해당 작업을 잡으려면하는 전화 약속을 해결하고 약속이 해결되면 supers 조치를 실행하는 함수.EmberJS은 - 약속 내가 엠버 2.6.0</p> <p>나는 행동에서 정의 된 일부 기능이 타사 구성 요소를 확장하고 사용하고
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
theAction() {
this._somePrivateFunction();
//do other stuff
}
}
});
을 그리고 내 하위 클래스에서 내가 뭐하는 거지 :
그래서 타사 구성 요소는이 작업을 수행 약속 콜백에서 호출 할 때
import Ember from 'ember';
import ThirdPartyComponent from 'path/to/component'
export default ThirdPartyComponent.extend({
_funcThatReturnsPromise() {
return new Ember.RSVP.Promise();
}
actions: {
theAction() {
const thePromise = this._funcThatReturnsPromise();
thePromise.then(() => {
// undefined!
this._super(...arguments);
})
}
}
});
this._super()
theAction() {
const thePromise = this._funcThatReturnsPromise();
this.set('superFunc', this._super);
thePromise.then(() => {
// calls the super but "this" inside the supers action is undefined
this._super(...arguments);
})
}
이
을 더하여 추 것에는 수퍼 액션 내부 this
결과는 정의되지한다. 내가 왜 그런지 모르겠다. 일부 문서를보고있다.
또한 내 서브 클래스의 행동에 send()
를 호출 할 수있는 옵션이 있습니다 :
theAction() {
const thePromise = this._funcThatReturnsPromise();
this.set('superFunc', this._super);
thePromise.then(() => {
//infinite loop!
this.send('theAction');
});
}
그러나 무한 루프에서이 과정의 결과 함수는 자신을 호출 끝 때문이다.
여기를 계속하는 방법을 모르겠습니다. 아무도 내가 여기에서하려고하는 것을 할 수있는 깨끗한 방법이 있다면 말해 줄 수 있습니까? 어떤 조언을 주시면 감사하겠습니다. 감사합니다! 하위 구성 요소에서
'상자 밖으로 작동합니다. – Bergi
@Bergi 예, 이상적인 경우가 될 것입니다. 그러나 Emberjs 구성 요소의 범위 내에서 작업하고 있습니다 .- ( – TheMethod