Comments (2)
The answer depends on whether you are planning on using any of the other capabilities of Ext.app.Application
. If you are using the Deft JS IoC container for dependency injection (instead of using the stores
, views
, models
configs in Ext.app.Application
) and Deft JS View Controllers (instead of Ext.app.Controller
and the controllers
config in Ext.app.Application
), chances are you don't not need Ext.app.Application
anymore.
If you want an application-wide event bus, you can configure the IoC container with one and inject it as needed. To do so, you simply configure the IoC container with an instance of Ext.util.Observable
to be injected wherever needed.
Deft.Injector.configure({
eventBus: 'Ext.util.Observable'
});
(This works because in addition to being usable as a mixin, Ext.util.Observable
can also be directly instantiated and used as a standalone event bus.)
If it turns out you still need Ext.app.Application
, you can configure the IoC container with the Ext.app.Application
instance as the value
, like so:
Ext.application({
name: 'MyApp',
launch: function() {
Deft.Injector.configure({
'application': {
value: this
}
});
// Create Viewport and views
...
}
});
I created an example of this approach on JSFiddle here: http://jsfiddle.net/CodeCatalyst/K2ZgR/
Deft.Injector.configure()
can be called multiple times in your application. Each time it is called it adds or updates the specified identifiers. In this case, you'll want to do the majority of your IoC container configuration in Ext.onReady()
and only configure the application reference within your Ext.app.Application
's launch()
method.
Be careful, though. If you use Ext.app.Application
's stores
or controllers
configs, the singleton instances it creates are instantiated before the Ext.app.Application
instance's constructor or launch()
method are fired. If you've instantiated classes that depend on the application
before then, Deft.Injector
will throw an error because the application
identifier can only be resolved after its been created and you've configured the IoC container with that reference.
from deftjs.
That's awesome John. Thank you a ton.
Deft is a much better solution than Sencha's first attempt at MVC.
Cheers,
Neil
On Tue, Jun 12, 2012 at 8:42 AM, John Yanarella <
[email protected]
wrote:
The answer depends on whether you are planning on using any of the other
capabilities ofExt.app.Application
. If you are using the Deft JS IoC
container for dependency injection (instead of using thestores
,views
,
models
configs inExt.app.Application
) and Deft JS View Controllers
(instead ofExt.app.Controller
and thecontrollers
config in
Ext.app.Application
), chances are you don't not need
Ext.app.Application
anymore.If you want an application-wide event bus, you can configure the IoC
container with one and inject it as needed. To do so, you simply configure
the IoC container with an instance ofExt.util.Observable
to be injected
wherever needed.Deft.Injector.configure({ eventBus: 'Ext.util.Observable' });(This works because in addition to being usable as a mixin,
Ext.util.Observable
can also be directly instantiated and used as a
standalone event bus.)If it turns out you still need
Ext.app.Application
, you can configure
the IoC container with theExt.app.Application
instance as thevalue
,
like so:Ext.application({ name: 'MyApp', launch: function() { Deft.Injector.configure({ 'application': { value: this } }); // Create Viewport and views ... } });I created an example of this approach on JSFiddle here:
http://jsfiddle.net/CodeCatalyst/K2ZgR/
Deft.Injector.configure()
can be called multiple times in your
application. Each time it is called it adds or updates the specified
identifiers. In this case, you'll want to do the majority of your IoC
container configuration inExt.onReady()
and only configure the
application reference within yourExt.app.Application
'slaunch()
method.Be careful, though. If you use
Ext.app.Application
'sstores
or
controllers
configs, the singleton instances it creates are instantiated
before theExt.app.Application
instance's constructor orlaunch()
method are fired. If you've instantiated classes that depend on the
application
before then,Deft.Injector
will throw an error because the
application
identifier can only be resolved after its been created and
you've configured the IoC container with that reference.
Reply to this email directly or view it on GitHub:
#21 (comment)
from deftjs.
Related Issues (20)
- DeftJS v0.9 - Promises not working in Internet Explorer 10 HOT 6
- Distribute packages separately. HOT 4
- Update Karma configurations from v0.8 -> v0.10 syntax HOT 1
- Add continuous deployment HOT 10
- Add Ext JS 4.2.2 to the Deft JS Test Suite HOT 2
- Add Sencha Touch 2.3.0 to the Deft JS Test Suite HOT 1
- Update the Test Suite dependencies (Mocha, Chai, Sinon, Promise/A+, etc.)
- Update to Promises/A+ Specification v1.1 and Test Suite v2.0
- Failing to require: the ViewController for a controller: annotation should trigger a warning.
- Sencha Cmd v4.0.0.203 hanging when "requires" : "[email protected]?" added HOT 14
- Migrate back to mixins for Sencha Cmd and Architect compatibility
- Suppress INFO-level log messages when not using the debug build of Sencha Touch HOT 1
- Superclass merging of ViewController 'control:' configurations
- ViewController companions HOT 4
- Touch 2.3.0 coverage report might overwrite 2.2.1 report
- deft.js and deft-debug.js are not in the repo HOT 1
- Sencha cmd 5.0.3 and touch 2.4.1 - build failed HOT 16
- Sencha 2 Routing with Deft JS.. HOT 1
- DeftJS 8.0-9.1Promise/Deferred Memory Usage HOT 5
- Promises catching errors happening in the success method HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deftjs.