_Templated オブジェクトに何かが起こったときに、特定のトピックを公開できるようにしたいと考えています。今、私は単純に追加のビットを混ぜてウィジェットを作成しています:
[...]
return declare('hotplate.hotDojoAuth.LoginForm', [_WidgetBase, _TemplatedHooksMixin, _TemplatedMixin, _WidgetsInTemplateMixin ], {
_TemplatedHooksMixin は単に出力します:
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/topic',
], function(
declare
, lang
, topic
){
return declare(null, {
templatedHooks: true,
constructor: function(){
this.templatedHooks = true;
topic.publish('hotplate/hotHooks/constructor', this);
},
buildRendering: function(){
topic.publish('hotplate/hotHooks/buildRendering/before', this);
this.inherited(arguments);
topic.publish('hotplate/hotHooks/buildRendering/after', this);
},
destroyRendering: function(){
topic.publish('hotplate/hotHooks/destroyRendering/before', this);
this.inherited(arguments);
topic.publish('hotplate/hotHooks/destroyRendering/after', this);
},
postCreate: function(){
topic.publish('hotplate/hotHooks/postCreate/before', this);
this.inherited(arguments);
topic.publish('hotplate/hotHooks/postCreate/after', this);
},
startup: function(){
topic.publish('hotplate/hotHooks/startup/before', this);
this.inherited(arguments);
topic.publish('hotplate/hotHooks/startup/after', this);
},
destroy: function(){
topic.publish('hotplate/hotHooks/destroy/before', this);
this.inherited(arguments);
topic.publish('hotplate/hotHooks/destroy/after', this);
}
});
}
);
質問:
1) 主に「this」、「arguments」、「inherited」を使用しているため、コードが繰り返されます。(特に this.inherited)。. 単純なパラメーターを使用して 1 つの関数を作成するためのヒントはありますか?
2) これは中途半端なやり方ですか? アイデアは、私のライブラリとは関係のない他のウィジェットが _Templated ウィジェットの内容を変更できるようにすることです。
3)これが良いパスである場合(コメント?)、私がパスを呼んでいる方法は正気だと思いますか?
ありがとうございました!
メルク。