22 Nov 2010 10:54 PM #1
Sencha Touch's MVC
Sencha Touch's MVC
I'm trying to wrap my head around the new MVC functionality of Sencha Touch these days.
I'm comparing it a bit with server-side MVCing. So far my oberservation is that it doesn't seem as easy and clear as on the server-side, where basically one controller action responds to on client/user request.
When looking at the Twitter example, I see "actions" in the controller as well as in the views, which confuses me.
For example the following methods:
twitter.views.SearchBar: onSubmit() twitter.views.Searches: onItemTap(), onItemSwipe() twitter.views.TimeLine: onContainerTap()
Shouldn't that stuff go into controllers? If yes, how? If no, why? How do you difference those actions with the actions managed by the controllers?
Thanks for any help for finding me the missing piece.
P.S. @Sencha, with ST 1.0 out the door, any info on when we can expect more info/documentation on the MVC stuff?
23 Nov 2010 6:11 AM #2
I have similar questions. Hope someone from Sencha is going to do a post on MVC this week as mentioned in other posts.
The code in routes.js seems clean, i.e. one that maps urls to controller/actions. But other events don't quite follow similar pattern; sometimes they are delegated to controller while sometimes they are handled the traditional way. Will be good to know the recommended best practices, especially for a relatively complex app with many views and events.
27 Nov 2010 8:28 AM #3
I think it's worth remembering that the MVC architecture is quite new, and not all the demos are making full use of it yet.
I have a personal goal to write plenty of tutorials and best practice docs for this, but please bear with us. We know there is lots more to do for documentation in general!
27 Nov 2010 8:50 AM #4
Thanks for your response, James!
I basically just needed a confirmation from Sencha's side that the examples are still incompletish and that I'm not overseeing something, especially since they always point people to those two examples (kiva & twitter).
I know that documentation is always work in progress, I'm cool with that.
Meanwhile, questions have to do it and actually should help with creating a documentation.
27 Nov 2010 8:24 PM #5
Ext.dispatch() and Ext.ControllerManager.get() sometimes helps~
and some views have "scope" and "handler" property can help you to hook up with a controller
but it's a truth that MVC in Sencha is hard to use, you need too many glue code to follow this pattern.
By olin in forum Sencha Touch 1.x: DiscussionReplies: 10Last Post: 20 Jan 2012, 10:10 AM
By Bucs in forum Sencha Touch 1.x: DiscussionReplies: 16Last Post: 2 Jul 2011, 12:19 PM
By lexer in forum Sencha Touch 1.x: DiscussionReplies: 10Last Post: 5 Apr 2011, 10:53 PM
By atulbahl in forum Sencha Touch 1.x: DiscussionReplies: 8Last Post: 24 Mar 2011, 12:33 PM