When using the [relatively new] MVC bits in Sencha Touch I find that 90% of my dispatch calls look something like:
Ext.dispatch({
controller: "customers",
action: 'show',
record: record
});
That's fine, and I like delegating the flow to the seperate controller code, rather than complicated paths of events, but I have yet to see any advantage over just doing something like:
controllers.customers.show({
record: record
});
Which is shorter and cleaner. I feel like I am just following the Ext.dispatch
pattern for the sake of it. My app doesn't benefit from push/pop url history for state, and that is the only reason I can see for using this longer more complex approach.
What am I missing? What do I gain from using Ext.dispatch to call controllers?
The beforedispatch event is handy in case you need to redirect them to another controller.
Using dispatch also lets me load the controller code as needed instead of all at once on page load. I cut my app's startup time in half that way.
You said your app didn't need it, but being able to set the historyUrl and directly link to pages would be the main benefit for other users I think.
So I guess it all depends on the app whether it makes sense to use it.
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