Book Image

Getting Started with Twitter Flight

By : Tom Hamshere
Book Image

Getting Started with Twitter Flight

By: Tom Hamshere

Overview of this book

<p>Flight is a lightweight, component-based JavaScript application framework developed by Twitter for Twitter.com. It is an exciting alternative to the complexities of modern MVVM frameworks, offering a minimal API that allows you to write fast, reliable, scalable applications with a minimum of boilerplate code.</p> <p>Getting Started with Twitter Flight offers the reader insight into why Flight was created and how to use it to build performant, powerful web apps from a unique perspective – that of someone who has had the opportunity to work directly with the team that created it. From a basic knowledge of JavaScript and jQuery, you will explore every aspect of Flight through practical examples and detailed explanations.</p> <p>Learn what separates Flight from other frameworks, why Flight was created, and why you should use it in your next project. Discover the power of Flight’s component-based architecture and use mixins, an exciting alternative to class-based inheritance, to create templating systems and data storage layers.</p> <p>Getting Started with Twitter Flight provides all you need to know to build everything from UI widgets to large-scale, data-driven applications.</p>
Table of Contents (22 chapters)
Getting Started with Twitter Flight
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using Flight's registry


It is possible to import Flight's registry module to provide access to advanced features around component management. The registry keeps track of which component is attached to which node. The following are a few useful methods:

findInstanceInfoByNode

Returns an array of all component instances for a given node:

registry.findInstanceInfoByNode(node)

findInstanceInfo

Return a component instance if it exists in the registry, otherwise null:

registry.findInstanceInfo(componentInstance)

allInstances

This is an array of all components in the registry. Here's an example using allInstances to tear down all components:

registry.allInstances.forEach(function(i) {
 registry.allInstances[i].instance.teardown();
});