struggling between Ext Controller and Deft ViewController

90 views
Skip to first unread message

Jacob

unread,
Dec 12, 2014, 11:24:49 AM12/12/14
to def...@googlegroups.com
I am just starting to develop an ST 2.4 app with Deft. I've already developed a complex Ext JS 4.2 app with Deft, but I'm starting this one with a fresh approach, trying to follow recommended practices and not "fight" the system, and using ST features that are not in Ext 4.

Some of the struggles I'm having are as follows, according to my understanding:
  1. Ext Controllers can not use Deft.Injector, because the controllers are created (i.e., injector resolves in constructor) before app launches (i.e., seemingly the earliest time when I would configure the injector).
  2. Deft ViewControllers can not use Ext Router, because the Router works in tandem with the Ext Application which only routes to Ext Controllers (which a Deft ViewController is not). Routing is very important to connect the views together and change state.
  3. Using Ext views and controllers requires defining all of them up front in the application at global level and instantiating them, which I do not want. I like how Deft does a better job of separating concerns, but I lose out then on using the Ext router.
Any thoughts?

Jacob

unread,
Dec 12, 2014, 2:06:23 PM12/12/14
to def...@googlegroups.com
I spent some more time trying to figure out either if I can make Ext Controllers do what I like about Deft ViewControllers, and vice-versa, while working with what Ext and Deft already provide. I could not really come up with a good solution.

So I took a different approach, and I think I have a plan of attack:

1) Use a 3rd party router library (https://github.com/flatiron/director) instead of Ext.Router, which allows for more flexibility about where/how routes are invoked (i.e., not just Ext Controller). I plan to use them in ViewControllers, and hopefully when Sencha brings the ExtJS 5 ViewController into Sencha Touch it will be a 1:1 upgrade of my routes to the Ext.Router.

2) Instead of using Ext Controllers for non-view control, I'd like to just create regular classes. This is because I don't want global scope, refs/controls or views, nor to deal with the Deft.Injector issue mentioned in my previous message.

Brian Kotek

unread,
Dec 12, 2014, 2:19:35 PM12/12/14
to deftjs
Sounds like a decent approach. I don't build Touch apps, so I don't have much experience with Sencha's older controllers or the Touch routing. My initial thought was to try and split up the responsibilities, using the Touch controllers to handle routing and orchestrate "application-level" behavior (like which navigation view is showing), but use Deft view controllers on the child views to manage the lower-level behavior (where all the work is actually going on).

--
Deft JS home page: http://deftjs.org/
Wiki: https://github.com/deftjs/DeftJS/wiki
For rules and tips on asking questions on the Deft JS mailing list: https://github.com/deftjs/DeftJS/wiki/Asking-Questions-on-the-Mailing-List
---
You received this message because you are subscribed to the Google Groups "Deft JS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deftjs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deftjs/4b1dfe7b-55d4-475d-9708-64294b723b0f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christian Fecteau

unread,
Dec 12, 2014, 2:20:04 PM12/12/14
to def...@googlegroups.com
Hi Jacob,

1. My app.js just call an init method which configures Deft.Injector before I instantiate an Ext.app.Application myself. So I can inject dependencies in my Ext controllers.

2. I developed my own router based on the ST one but with more features. I init my routes in the init method of my Ext controllers.

3. My Ext controllers are just used for actions that create views/Deft VC.

> --
> Deft JS home page: http://deftjs.org/
> Wiki: https://github.com/deftjs/DeftJS/wiki
> For rules and tips on asking questions on the Deft JS mailing list: https://github.com/deftjs/DeftJS/wiki/Asking-Questions-on-the-Mailing-List
> ---
> You received this message because you are subscribed to the Google Groups "Deft JS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to deftjs+un...@googlegroups.com.

Jacob Gur

unread,
Dec 12, 2014, 3:15:13 PM12/12/14
to def...@googlegroups.com
Thanks Brian for the reply. The problem with using Ext Controllers for routing is that it bubbles the lower level details up the stack, since Ext Controllers are pre-initialized by app.js (although I could use private methods to create them later and add them to the application) and I also don't want to have to create Ext Controllers to manage all those details (that's what view controllers are for).

Ext JS 5 is nice, because it is much more flexible: it supports view controllers as first-class controllers with all the features including routing, and it lets you declare views and controllers in a nested and scoped manner.


You received this message because you are subscribed to a topic in the Google Groups "Deft JS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/deftjs/OSvd7YWsms8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to deftjs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deftjs/CAB06vMBxzVMbtTys5DiNgbLA%3DFLEBr5dwERFNs6v_Cce6_Qm9w%40mail.gmail.com.

Jacob Gur

unread,
Dec 12, 2014, 3:22:06 PM12/12/14
to def...@googlegroups.com
​Thanks for the reply Christian.

1. I'm not sure I want to configure the injector before Ext is ready. Or did you override Ext.application method to configure the injector? I guess the latter would work. In any event, I'm not sure I need Ext controllers at this point, but if I do I might try that.

​2. ​Sounds like you took a similar approach.

3. I'm thinking of just creating one Ext controller as a Launcher to create non-Ext controllers which manage various sub-systems of my app, such as UIManager, SyncManager, etc. The reason for Launcher is I'd like to keep app.js as generic as possible.


You received this message because you are subscribed to a topic in the Google Groups "Deft JS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/deftjs/OSvd7YWsms8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to deftjs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deftjs/CAAsoHeY%3DoK36tKcqr0qaEhhxA-hU3vt22LO8SqM6ki_moUgE%2Bw%40mail.gmail.com.

Christian Fecteau

unread,
Dec 13, 2014, 3:35:31 PM12/13/14
to def...@googlegroups.com
I don't use the Ext.application method. If you look at it it doesn't do much. I simply extend Ext.app.Application and instantiate it myself in an Initialization class that does everything (optionally async) needed before, during and after app creation. So app.js simply calls my Initialization class. Keeping app.js generic was too restricting for my needs. 

Here's my app.js:
Ext.require([
'App.Initialization'
]);
Ext.onReady(function() {
App.Initialization.init();
});

And here's what the init method looks like:
init: function() {
var me = this;
me.beforeCreateApplication().then(function() {
Ext.create('App.Application', {
init: function() {
me.beforeInitControllers();
},
launch: function() {
me.beforeCreateViewPort().then(function() {
me.createViewPort();
});
}
});
});
},


Jacob

unread,
Dec 13, 2014, 7:13:47 PM12/13/14
to def...@googlegroups.com
Thanks for the info. I may take that approach.

Your app.js still looks generic. Not Ext boilerplate, but at least it's not app-specific. 
Reply all
Reply to author
Forward
0 new messages