以前咱们对PureMVC中涉及到观察者模式的三个基本类(Notification/Observer/Notifier)进行了分析,接下来将对PureMVC源码中的其余类进行分析,首先咱们讲解SimpleCommand类。mvc
function SimpleCommand () { }; SimpleCommand.prototype= new Notifier; SimpleCommand.prototype.constructor= SimpleCommand;
因为继承了Notifier类,SimpleCommand类继承了Notifier类的sendNotification()方法,故说它能够扮演通知者角色。app
/** * Fulfill the use-case initiated by the given Notification * * In the Command Pattern, an application use-case typically begins with some * user action, which results in a Notification is handled by the business logic * in the #execute method of a command. * * @param {puremvc.Notification} notification * The notification to handle. * @return {void} */ SimpleCommand.prototype.execute= function (notification) { };
execute()方法,接受一个notifcation对象做为参数,可是至于什么时候会调用execute()方法咱们如今还不清楚,先放着,记着SimpleCommand有这个方法。spa