A collection of Flight mixins that aids in communicating with backend services.
bower install --save flight-towerThis mixin will emit life cycle and success/fail events for an ajax request.
get(url, eventName[, data])post(url, data, eventName)ajax(url, ajaxOptons, eventName)-
redoRequest(failData)- will try forredoRetriestimes max, default 10.
.get/.post are both thin wrappers around .ajax which in turn is
a thin wrapper around $.ajax`.
All methods returns the jQuery promise from $.ajax in case you want to add your own callback to the mix.
All events are created out of the eventName you pass in. The examples
all use the event Example.
The event names are based off of the suggested naming conventions in Getting Started with Twitter Flight.
All:
-
dataExample- a successful request -
dataExampleFail- a failed request
dataExampleFail will trigger with the data to reproduce the request
as well as status and response from the server.
GET/HEAD events:
fetchExampleStartfetchExampleEnd
POST/PUT/PATCH events (any other than get/head):
submitExampleStartsubmitExampleEnd
define(function(require) {
var defineComponent = require('flight/lib/component'),
withAjax = require('flight-tower/lib/with_ajax');
return defineComponent(formData, withAjax);
function formData() {
this.defaultAttrs({
redoRetries: 10
});
this.after('initialize', function() {
this.get('/some-data', 'Countries');
this.post('/submit', {user: 'test', password: 1234}, 'UserLogin');
this.ajax('/submit', {data: {user: 'test', password: 1234}}, 'UserLogin');
});
}
});Development of this component requires Bower to be globally installed:
npm install -g bowerThen install the Node.js and client-side dependencies by running the following commands in the repo's root directory.
npm install & bower installTo continuously run the tests in Chrome during development, just run:
npm run watch-testAnyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.

