Skip to content

Latest commit

 

History

History
80 lines (53 loc) · 2.07 KB

README.md

File metadata and controls

80 lines (53 loc) · 2.07 KB

flight-with-resources

Build Status

A Flight mixin for sharing named resources between components. A component can provide a resource into a central registry which other components can subsequently request. On component teardown any provided resources are removed.

Installation

bower install --save flight-with-resources

Example

Here's an example of two component definitions that use withResources.

function providingComponent() {
    this.after('initialize', function () {
        this.provideResource('appManifest', {
            versionNo: '1.0.1',
            buildNo: '1234',
            url: 'https://tweetdeck.twitter.com'
        });
    });
}

function requestingComponent() {
    this.after('initialize', function () {
        var versionNo = this.requestResource('appManifest').versionNo;
    });
}

API

provideResource

provideResources, takes the name of the resource that is being provided, and then the resource itself. The resource can be any JavaScript type, including a function.

requestResource

requestResource takes the name of the resource being requested and returns the requested resource.

removeResource

removeResource takes the name of a resource to be removed.

Development

Development of this component requires Bower to be globally installed:

npm install -g bower

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

npm install & bower 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.