GithubHelp home page GithubHelp logo

mikesimard / angular-couchpotato Goto Github PK

View Code? Open in Web Editor NEW

This project forked from afterglowtech/angular-couchpotato

0.0 1.0 0.0 217 KB

Lazy-Load and Register Components in AngularJS Applications

License: Other

angular-couchpotato's Introduction

Version 0.0.5 of afterglowtech/angular-couchPotato intentionally throws an error.

Version 0.0.4 is the last functional version on this branch. Please migrate. Version 0.0.5 in that repository is functionally identical to 0.0.4 in this repository.

Following is the old readme.

angular-couchPotato: Lazy-Load and Register Components in AngularJS Applications

couchPotato aids in the lazy download and registration of services, directives, controllers and filters just-in-time. It supports hierarchies of dependencies within these components. Applications can use couchPotato to download and register components when they are needed to satisfy the requirements of a given route.

Applications specify dependencies of their routes when the routes are configured. Those dependencies are kept in a promise function. When the routes are invoked, the promise function is resolved, and the couchPotato provider uses the AMD api to download the dependencies (which are defined as AMD modules). The dependencies invoke the couchPotato service to register themselves. Since each component registers itself, indirect dependencies specified in AMD form are downloaded and registered along with the directly stated dependencies of the route. couchPotato does not care which dependencies are resolved when the route is invoked. It is an application's responsibility to specify directly or indirectly all requirements.

See the README in the sample apps for basic demonstrations.

General Usage

better instructions are needed -- for now it's probably easier to look at the samples

  • Download the angular-couchPotato.js file from the src directory in this repository or depend on the the repository using bower.

  • Reference the script file in your application.

  • Your application module should depend on the 'agt.couchPotato' module.

  • Inject the $couchPotatoProvider when defining routes and wrap the definitions of lazy portions of the route specification in a call to the provider's lazyLoad function, which takes an anonymous object with all of the normal Angular core properties, and an additional "dependencies" property, which is an array of AMD modules that will be loaded when the route is invoked.

  • Inject the $couchPotato service in an application module run function, and maintain a property accessible to the lazy component's define modules so that they can access the service within their definitions in order to register themselves.

History/Attribution

At this time, couchPotato is essentially a formalization of a portion of some angular seed apps that demonstrate this technique. One of them is angular-require-lazyload, from which code was copied directly and reorganized/repackaged. Aside from leveraging the dependency-management features of AMD to chain dependencies, it doesn't have any additional features when compared to these seed apps.

License

See the LICENSE file.

Questions/Comments/Concerns

See the Issues List. Yes, couchPotato really is just small a page of code before minimization. Short and sweet. It's about the pattern...

angular-couchpotato's People

Contributors

laurelnaiad avatar

Watchers

James Cloos 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.