GithubHelp home page GithubHelp logo

mikemliu / flight-with-child-components Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flightjs/flight-with-child-components

0.0 2.0 0.0 184 KB

Flight mixin for nesting components. Built by TweetDeck.

Home Page: http://flightjs.github.io/

License: MIT License

flight-with-child-components's Introduction

flight-with-child-components

Build Status

A Flight mixin for nesting components by coupling their life-cycles, making sure that a component and its children are torn down together.

A component that intends to initialize child components should mix in withChildComponents and attach the children using this.attachChild.

The child will be passed an even to listen out for โ€“ when it's triggered, the child will teardown. withChildComponents mixin adds a unique event name to the parent (this.childTeardownEvent) for this use, but you can manually specify a teardownOn event name in the child's attrs.

This construct supports trees of components because, if the child also mixes in withChildComponents, it's childTeardownEvent will be fired before it is torn down, and that will teardown any further children in a cascade.

Installation

bower install --save flight-with-child-components

Example

In the parent component, mixin withChildComponents into the parent.

var withChildComponents = require('path/to/the/mixin');
var ChildComponent = require('some/child');
var AnotherChildComponent = require('some/other/child');

return defineComponent(parentComponent, withChildComponents);

function parentComponent() {

  this.after('initialize', function () {
    // this.attachChild does all the work needed to support nesting
    this.attachChild(ChildComponent, this.select('someChild'));

    // it supports the same API as 'attachTo'
    this.attachChild(AnotherChildComponent, '.another-child', {
      teardownOn: 'someEvent'
    });
  });

}

Development

Install the Node.js and client-side dependencies by running the following commands in the repo's root directory.

npm install

To continuously run the tests in Chrome during development, just run:

npm run watch-test

Contributing to this project

Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.

flight-with-child-components's People

Contributors

passy avatar tgvashworth avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.