You are previewing Getting Started with Twitter Flight.
O'Reilly logo
Getting Started with Twitter Flight

Book Description

Build scalable, modular JavaScript applications with the Twitter Flight framework

  • Learn how to build scalable, maintainable, modular applications with Flight, Twitter’s cutting-edge JavaScript framework

  • Work through building a simple application from scratch with clear, step-by-step examples

  • Leap ahead of the learning-curve with best practice examples from an experienced Flight developer

In Detail

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.

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.

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.

Getting Started with Twitter Flight provides all you need to know to build everything from UI widgets to large-scale, data-driven applications.

Table of Contents

  1. Getting Started with Twitter Flight
    1. Table of Contents
    2. Getting Started with Twitter Flight
    3. Credits
    4. Foreword
    5. About the Author
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Errata
        2. Piracy
        3. Questions
    9. 1. What is Flight?
      1. Who made Flight?
      2. How does Flight work?
        1. Event-driven interfaces
        2. Scalable architecture
          1. No parent-child relationships
          2. No spaghetti code
          3. Promoting reusability with well-defined interfaces
        3. The missing model
          1. Simplification
          2. Reducing boilerplate
      3. Summary
    10. 2. The Advantages of Flight
      1. Simplicity
      2. Efficient complexity management
      3. Reusability
      4. Agnostic architecture
      5. Improved Performance
      6. Well-organized freedom
      7. Summary
    11. 3. Flight in the Wild
      1. Flight at Twitter
        1. Better performance
        2. A manageable codebase
      2. Quotes from developers
        1. On refactoring
        2. On Flight's component architecture
      3. Open source Flight projects
        1. TodoMVC
        2. Components for web applications
      4. Extending Flight with two-way data binding
      5. Summary
    12. 4. Building a Flight Application
      1. Scaffolding a Flight application with Yo
        1. Installing Yo
        2. Understanding the application structure
        3. Running the application
      2. Creating custom applications
      3. Using Flight without a module loader
      4. Troubleshooting
      5. Debugging
      6. Summary
    13. 5. Components
      1. What is a component?
      2. Component types
        1. Mixins
      3. Creating your first component
        1. Attaching components to the DOM
        2. Performing actions on component initialization
      4. Summary
    14. 6. UI Components
      1. Attaching components to existing HTML
      2. Listening for browser events
        1. Attaching event handlers
        2. Defining event handlers
      3. Finding DOM nodes
        1. Setting default attributes
        2. Using attributes to select nodes
        3. Triggering custom events in Flight
        4. Triggering events on specific elements
        5. Event names
        6. Event data
      4. Modifying the DOM
      5. Summary
    15. 7. Data Components
      1. What is a data component?
      2. Attaching data components
      3. Naming data events
      4. Creating a data component
      5. Listening for UI events
      6. Event handlers
      7. Triggering data events
      8. Completing the task_data component
        1. handleNeedsTask
        2. handleNeedsTasks
        3. handleTaskCompleted
      9. Error handling
      10. Handling data events
      11. Summary
    16. 8. Event Naming
      1. The importance of event names
      2. Events are not instructions
      3. Suggested naming conventions
      4. Summary
    17. 9. Mixins
      1. What are mixins?
      2. When to use mixins
      3. How do mixins work?
      4. Creating mixins
      5. Using mixins
      6. Mixin priority
      7. Creating your first mixin
        1. Mixing storage into taskData
      8. Initializing the task list from storage
      9. Extending existing methods
        1. before and after
        2. around
      10. Advice priority for components and mixins
      11. Mixing mixins into mixins
      12. Summary
    18. 10. Templating and Event Delegation
      1. Generating template objects from DOM nodes
      2. Constructing templates in components
      3. Creating a templating mixin
      4. Server-side compilation
      5. Using HTML to determine state
      6. Working with dynamic HTML – event delegation
      7. Adding delegated events to task_list
        1. Completing a task
      8. Summary
    19. 11. Web Application Performance
      1. Reducing time to page load
        1. Deferred loading
      2. Server-side rendering
      3. Using the DOM to determine state
      4. Using request type to determine response
      5. Perceived performance
        1. Applying perceived performance in Flight
      6. Summary
    20. 12. Testing
      1. What does a test look like?
      2. Testing the interface
      3. Obtaining a reference to a component instance
      4. Instantiating standalone mixins
      5. Triggering browser events
      6. Allowing for refactoring
      7. Testing teardown
      8. Testing component instantiation
      9. Extending Jasmine for Flight
        1. Jasmine and AMD
        2. Event assertions
        3. Testing whether methods have been called
      10. Summary
    21. 13. Complexities of Flight Architecture
      1. The danger of nested components
        1. Teardown
        2. Atomic components
        3. Testing
      2. Creating a flat component structure
      3. Mixins versus components
        1. Working with components
        2. Working with mixins
      4. Summary
    22. A. Flight API Reference
      1. Components
        1. Component definition
        2. Mixin definition
        3. Using mixins
        4. Instantiating components
        5. Methods available on a component instance
          1. Advice
            1. before
            2. after
            3. around
            4. Initialization
          2. defaultAttrs
          3. select
          4. Events
            1. on
            2. off
            3. trigger
          5. teardown
      2. Using Flight's registry
        1. findInstanceInfoByNode
        2. findInstanceInfo
        3. allInstances
    23. Index