PDA

View Full Version : How to use Ext.dispatch( ) in Touch 2.x or an action controller



losingrose
1 Dec 2011, 7:12 PM
I hope the controller of Touch 1.x will be realized in Touch 2.x .
But now I'm very disappointed that the controller of Touch 2.x was made like Extjs 4.x .
The controller should be like an container with many of actions in mvc.In views we can call any action in events.It's the true MVC Framework like in touch 1.x .
In Touch 2.x and Extjs 4.0 the controller is without any action and was designed to be a listeners manager of the view.I can not understand the mean of this design.It will cause the controller is limited by the view design.

My English is not so good, bear with me a lot.I want that Ext.dispatch() and action controller will be realized in Touch 2.x .

rdougan
1 Dec 2011, 8:00 PM
There is a lot of work being done with MVC before the GA release of Sencha Touch 2. Bare with us.

TruMan1
12 Dec 2011, 2:56 PM
Anything we can use in PR3? I don't see how MVC can work properly without this.

rdougan
12 Dec 2011, 6:42 PM
None of the work being done on MVC has made it into any of the Preview Releases. It will however be in for final release.

TruMan1
13 Dec 2011, 6:12 AM
That is heartbreaking :s. I urge you to reconsider. We would love to test and provide feedback on the MVC implementation even if it is not set in stone. Besides, how are we supposed to put Touch 2 through real world testing if there is no way for us to build up our own architecture.

ideamonk
13 Dec 2011, 6:27 AM
The way to MVC is pretty unclear right now. I couldn't get Ext.dispatch working. Though after study of examples, I figured out that this.getController('App.controller.Foo') loads up /App/controller/Foo.js

So the show could be called up from a main controller as this.getController('App.controller.Foo').show()

I switched from PR2 to PR3 recently. I'm doing my current development on preview releases so as to have minimum friction when ST2 comes out. But I hope architecture guesswork from examples would hold in final release too.

My app has this structure -

29970

I've grown pretty comfortable to this!

rdougan
13 Dec 2011, 9:34 AM
@TruMan1

Sorry, I cam across wrong. It will make it into one of the releases before the final.

@ideamonk

The structure won't change much at all, and structures like that should still work in the 2.0 final.

basememara
13 Dec 2011, 9:38 PM
The way to MVC is pretty unclear right now. I couldn't get Ext.dispatch working. Though after study of examples, I figured out that this.getController('App.controller.Foo') loads up /App/controller/Foo.js

So the show could be called up from a main controller as this.getController('App.controller.Foo').show()

I switched from PR2 to PR3 recently. I'm doing my current development on preview releases so as to have minimum friction when ST2 comes out. But I hope architecture guesswork from examples would hold in final release too.

That is good stuff! But how do you get your actions to render your views and pass the values to it?

ideamonk
13 Dec 2011, 10:31 PM
My main view, or the viewport is a NavigationView and actually in every controller's show method, I'm getting the main view, via the refs system, and doing a push.

E.g. show of the Menu controller -


show: function() {
this.getMain().push( this.getMenuView() );
}


and refs look like this -


refs: [
{
ref : 'main',
selector: '#mainView',
},
{
ref: 'menuView',
selector : 'menuView'
},
]


My Main view is loading up every other view via requires: [ ... ], and has every view used in the app inside its items.

For passing values, lets say while I've to reveal a menu item, the show method of details view should have an id parameter. The details view would do appropriate data store calls, place in loading spinner, and remove when data comes in. The controls like list that are bound to data store would get rendered automatically, while if I've some other complex components, I could target them via refs and change them from controller.

basememara
15 Dec 2011, 8:34 AM
Thanks for the help @ideamonk. I just posted a blog article regarding MVC and Touch 2. I hope it helps someone:
http://blog.falafel.com/blogs/basememara/11-12-15/Building_a_Mobile_Web_App_using_Sencha_Touch_2_and_MVC.aspx