Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's a good question. The Sidebar example should illustrate this pretty well.

Current scenario:

1. The user clicks the remove file button [-] at the bottom of the Sidebar.

2. The Sidebar fires an 'intent:fileRemove' event through the mediator.

3. The handler of this event can then determine which file should be deleted and can also prompt the user to confirm their intentions.

4. If the user confirms that they want to delete, then the model is changed and the 'event:fileRemove' event is fired off.

5. The UI then reacts to this event.

If the Sidebar instead fired of an 'event:fileRemove' directly this would lead to some issues:

* The Sidebar would need to take over the responsibility of prompting the user about file deletion.

* If I add a new UI entry-point to file removal, this user prompting behaviour needs to be duplicated.

TLDR; It buys me extra decoupling between user intentions (UI -> Model) and state changes (Model/Controller -> UI). It lets me add a Menu with a Remove item without needing to change my controller and model to accommodate it.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: