以前咱們對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