Fundamentals - App Config & Startup - V

Organizing App with Features:

- Related functionality that collectively form a 'feature' can be added to Aurelia app, without interfering with the other parts of the app
- Rather than place the feature's configuration logic inside the app's configuration module, can place the feature's configuration inside 
e.g. my-component-1 & my-component-2 form a logical feature, lets called my-feature
To create a feature,
- Create a folder in app, my-feature
- Inside folder, place all the components & other code that pertain to that feature.
- Create an index.js file at the root of the my-feature folder. File should export a single configure function

A Feature Module (index.js) in ES Next

export function configure(config){
            config.globalResources(['./my-component-1', './my-component-2']);
}

Using a Feature in ES Next

export function configure(aurelia){
           aurelia.use.standardConfiguration( )
                            .developmentLogging( )
                            .feature('my-feature');
           aurelia.start( ).then(( ) => aurelia.setRoot( ));
}

Comments

Popular posts from this blog

Fundamentals - App Config & Startup - VIII

Fundamentals - Dependency Injection V

Style vs Css attribute