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 somethingApplication.trigger - is the same as Application.execute.What's the difference between Application.trigger and Application.execute?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With