DeftJS

Essential extensions for enterprise web and mobile application development with Ext JS and Sencha Touch.

About

DeftJS enhances Ext JS and Sencha Touch's APIs with additional building blocks that enable large development teams to rapidly build enterprise scale applications, leveraging best practices and proven patterns discovered by top RIA developers at some of the best consulting firms in the industry.

Goals

Flexibility

Coordinates dynamic assembly of object dependencies based on a configurable IoC container.

In this case, the contactStore dependency will be resolved into a new store property.

A class does not need to explicitly define a config or property for the property to be injected. However, if that property is defined as an existing config (even in a superclass), the Injector will correctly populate the config value.

Deft.mvc.ViewController

A lightweight controller for a view, responsible for managing the state of the view and its child components, listening for events dispatched by the view and its child components in response to user gestures, and delegating work to injected business services (such as Stores, Models, Managers, etc.).

The ViewController is an abstract base class which can be extended to create view-specific view controllers.

In this example, in addition to creating and adding a getSubmitButton() accessor, the view controller will add a click event listener to the Button with an itemId of submitButton in the corresponding view.

NOTE: The specified event listener will be called in the view controller's scope.

Standard event listener options such as buffer, delay, scope, single and element can be specified for a given view component event using slightly more verbose syntax:

As an alternative to relying on matching component itemId's, the control annotation can be configured to both reference a component by a view-relative component query selector and add event listeners, using slightly more verbose syntax:

NOTE: The getView() accessor is always available, regardless of whether you explicitly create a reference and add event listeners to view.

After the view has been initialized or rendered for the first time, the view controller's init() template method will be called.

Ext.define( 'MyApp.controller.ContactsViewController', {
extend:'Deft.mvc.ViewController',
...
control: {
...
}
...
init:function() {
// all accessors will have been created and all event listeners will have been addedreturnthis.callParent( arguments );
}
});

When the destroy() is called on the view, the view controller's destroy() template method is called. If this method returns false, view destruction will be cancelled. If this method returns true, the view will be destroyed, and all references and event listeners created in the view controller using control will automatically be removed.

The corresponding view controller class is specified using the controller annotation.

In this case, whenever an instance of ContactsView is created, an instance of the ContactsViewController will also be created and associated with that view instance.

Consequently, multiple independent instances of a given view class can be created, each with their own independent view controller instances. Views can communicate by interacting with shared injected business services. Nested views can also communicate via custom events.

Provided the specified controller extends Deft.mvc.ViewController, the controller will automatically be destroyed when the view is destroyed.