What's the difference between Marionette's Application.execute and Application.trigger methods?

backbone.js, marionette

Solution

When A calls `execute`, it orders B to do something. There's a somewhat direct link: one orders, the other executes (i.e. something must happen).

Triggers simply trigger an event to indicate something happened in the application. Other sections of the code might be listening for that event and react to it, but it also possible that no one is listening (so nothing will happen). Basically, by using triggers you can easily implement a publish/subscribe pattern in your application.

For completeness, there's also a `triggerMethod` call in Marionnette: it triggers the "some:event" signal, but also executes the `onSomeEvent` function if applicable. For example, `myView.triggerMethod("some:event")` will trigger the "some:event" within the `myView` scope and call `myView.onSomeEvent`.

Problem

According to the docs, `Marionette.Application` provides three "action" methods: - `Application.execute` - execute some action but register it first with `MyApp.command('action', function () {});` - `Application.request` - is like `Application.execute` but can return something - `Application.trigger` - is the same as `Application.execute`. What's the difference between `Application.trigger` and `Application.execute`?

Original source