A look at flightjs/flight: 6.5k stars on GitHub, written primarily in JavaScript. A component-based, event-driven JavaScript framework from Twitter
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Flight is not under active development. New pull requests will not be accepted unless they fix core bugs or security issues.
Flight
Flight is a lightweight, component-based,
event-driven JavaScript framework that maps behavior to DOM nodes. It was
created at Twitter, and is used by the twitter.com and
TweetDeck web applications.
Website
API documentation
Flight example app (Source)
Flight's Google Group
Flight on Twitter
Flight on Freenode IRC (#flightjs)
Example
A simple example of a Flight component.
/* Component definition */
var Inbox = flight.component(inbox);
function inbox() {
this.doSomething = function() { /* ... */ }
this.doSomethingElse = function() { /* ... */ }
// after initializing the component
this.after('initialize', function() {
this.on('click', this.doSomething);
this.on('mouseover', this.doSomethingElse);
});
}
/* Attach the component to a DOM node */
Inbox.attachTo('#inbox');
Installation
Quick start using the pre-built
library (a
UMD bundle). It exposes all of its modules as
properties of a global variable, flight.
Flight is only ~5K minified and gzipped. It's built upon jQuery.
Flight components are highly portable and easily testable. This is because a
Flight component (and its API) is entirely decoupled from other components.
Flight components communicate only by triggering and subscribing to events.
Flight also includes a simple and safe
mixin
infrastructure, allowing components to be easily extended with minimal
boilerplate.
Development tools
Flight has supporting projects that provide everything you need to setup,
write, and test your application.
Flight generator
Recommended. One-step to setup a Flight-based web app.
Flight package generator
Recommended. One-step to setup everything you need to write and test a
standalone Flight component.
Jasmine Flight
Extensions for the Jasmine test framework.
Mocha Flight
Extensions for the Mocha test framework.
Finding and writing components
You can browse all the Flight components
available at this time. They can also be found by searching the Bower registry:
bower search flight
The easiest way to write a new Flight component is to use the Flight
package generator:
Here's a brief introduction to Flight's key concepts and syntax. Read the API
documentation for a comprehensive overview.
Components (API)
A Component is nothing more than a constructor with properties mixed into its prototype.
Every Component comes with a set of basic functionality such as event handling and component registration.
(see Base API)
Additionally, each Component definition mixes in a set of custom properties which describe its behavior.
When a component is attached to a DOM node, a new instance of that component is created. Each component
instance references the DOM node via its node property.
Component instances cannot be referenced directly; they communicate with other components via events.
Interacting with the DOM
Once attached, component instances have direct access to their node object via the node property. (There's
also a jQuery version of the node available via the $node property.)
Events in Flight
Events are how Flight components interact. The Component prototype supplies methods for triggering events as
well as for subscribing to and unsubscribing from events. These Component event methods are actually just convenient
wrappers around regular event methods on DOM nodes.
Mixins (API)
In Flight, a mixin is a function which assigns properties to a target object (represented by the this
keyword).
A typical mixin defines a set of functionality that will be useful to more than one component.
One mixin can be applied to any number of Component definitions.
One Component definition can have any number of mixins applied to it.
Each Component defines a core mixin within its own module.
A mixin can itself have mixins applied to it.
Advice (API)
In Flight, advice is a mixin ('lib/advice.js') that defines before, after and around methods.
These can be used to modify existing functions by adding custom code. All Components have advice mixed in to
their prototype so that mixins can augment existing functions without requiring knowledge
of the original implementation. Moreover, since Components are seeded with an empty initialize method,
Component definitions will typically use after to define custom initialize behavior.
Debugging (API)
Flight ships with a debug module which can help you trace the sequence of event triggering and binding. By default
console logging is turned off, but you can log trigger, on and off events by means of the following console
commands.
Authors
@angus-c
@danwrong
@kpk
Thanks for assistance and contributions:
@sayrer,
@shinypb,
@kloots,
@marcelduran,
@tbrd,
@necolas,
@fat,
@mkuklis,
@jrburke,
@garann,
@WebReflection,
@coldhead,
@paulirish,
@nimbupani,
@mootcycle.
Special thanks to the rest of the Twitter web team for their abundant
contributions and feedback.
License
Copyright 2013 Twitter, Inc and other contributors.
flightjs/flight has 6.5k GitHub stars — refresh the page for the live number, or check github.com/flightjs/flight. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is flightjs/flight open source?
Yes — flightjs/flight ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/flightjs/flight.
What is flightjs/flight?
flightjs/flight (flightjs/flight) is a JavaScript project on GitHub. From the project's own README: A component-based, event-driven JavaScript framework from Twitter
Where can I see flightjs/flight in action?
The project maintains a homepage at http://flightjs.github.io/. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about flightjs/flight?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/flightjs/flight is the definitive source.
Read full README in the tab above.
Is flight worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of flight.