条件でEmberクラスを拡張することはできますか?このような何か:条件でEmberクラスを拡張する
A.reopen({
if (condition) {
init: function() {
this.super();
// some functionality
}.on('didInsertElement');
}
})
現在、私はこのようなパターンを持っている:
A.reopen({
if (condition) {
init: function() {
this.super();
// some functionality
}.on('didInsertElement'),
clear_up: function() {
// some stuff
}.on('willDestroyElement')
}
})
すべて:
A.reopen({
init: function() {
this.super();
if (condition) {
// some stuff
}
}.on('didInsertElement'),
cleanup: function() {
if (condition) {
// some stuff
}
}.on('willDestroyElement')
})
は、私は条件にクラスを拡張することができれば、私はこのように私のパターンを簡素化することができます推測プラグインで作成したクラス拡張機能discourse
なぜ、1行目と2行目を切り替えるのですか?どのクラスを再オープンし、ユースケースは何ですか? – Keo
@Keo私のケースを明確にするために質問を更新しました – megas
Keoの回答はあなたに役立ちませんか? 'if(条件){ A.reopen({' – ykaragol