I have a wizard with each step a form. On click of next wizard calls form.validate()
and then switches to the ne开发者_如何学Pythonxt card. Validate does all sorts of business validation + basic form validation.
I have an abstract superclass for all the forms that just does this.getForm().isValid()
and the subclasses can override this to put their specific logic. Downside to this in extjs4 is u still have to implement this in ur view classes thus the mvc separation is not upheld.
Now what if in extjs4 we changed the validate from being a method to an event ?, for which all subclasses should define a handler and the wizard class on click of next just fires that event ?
This serves 2 purposes :
- it will make the call asynchronous
- u can implement ur business logic within controller classes.
The downside here is there is no way of providing a default implementation that can be shared like a default implementation in base class. Even if you have the base class implement a default handler for that event the downside to that model is unlike inheritance based sharing u can't decide to turn off that behavior by not calling this.callParent(arguments)
.
So the missing piece here is how is it possible to have a inheritance-like reuse possible in a event based paradigm ?
精彩评论