mohammedzamakhan / ngx-loadable

⏳ Simple Lazy Loading for Non Routable Angular Modules
https://mohammedzamakhan.github.io/ngx-loadable/
MIT License
165 stars 21 forks source link

ngx-loadable

All Contributors

npm license size

ngx-loadable logo The library logo represents faster application like speed of wind

Table of Contents

Problem

Angular provides an easy way for adding route based lazy loading modules. But in most of the projects, each route tends to have a lot of different components. It could be because of lots of modals, tabs, and components that appear based on user interaction in a single route.

Solution

The ngx-loadable wraps the complex implementation for lazy loading non routable modules in a simple API. It provides a component ngx-loadable and a service LoadableService to lazy load modules. A component can be used to control the loading of one module and to display different states, i.e. loading, error, timedOut and loaded.

Install

Install and manage the ngx-loadable using NPM. You may use yarn or npm.

npm install ngx-loadable --save

or

yarn add ngx-loadable

Usage

NgModule

Import the LoadableModule in the NgModule and declare them in the "imports", you can also use the forRoot() for forChild() function.

import { LoadableModule } from 'ngx-loadable';

@NgModule({
  imports: [
    LoadableModule
  ]
})

or use the LoadableService

import { LoadableService } from 'ngx-loadable';
...
class YourComponent {
    contructor(private loadableService: LoadableService) { }
    load() {
        this.loadableService.preload('lazy')
            .then(() => console.log('loaded'))
            .catch((error) => console.error(error));
        }
    }
}

Contribute

Contribution guidelines for this project

License

Β© 2019 ngx-loadable. All Rights Reserved.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Zama Khan Mohammed
Zama Khan Mohammed

πŸ’» 🎨 πŸ’‘ πŸ“– πŸ€” πŸš‡
rumanhassan
rumanhassan

πŸ€” πŸ’» πŸ”§
aijazkhan81
aijazkhan81

πŸ–‹
Aditya Menon
Aditya Menon

πŸ“–
David WΓΌrfel
David WΓΌrfel

πŸ›
Michael Reeves
Michael Reeves

πŸ“–
siddharthpal
siddharthpal

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!