Basics!!!!
One of the amazing things you can do with Aurelia, that one can't with any other framwewok/library, is model entire application using plain ES Next.
Inside of view, one has access to all the properties & methods of the class instance associated with that View & can access them inside the content of any element/attribute by using the ES Next template string syntax
e.g. <template>
<h1> ${heading}</h1>
</template>
${heading} - one way data binding to heading property
- data flow is unidirectional & only changes to the heading property will affect the view
- no "reverse" flow from the view back to the view-model
Aurelia flexible to supports patterns like
1. Model-View-View-Model pattern
2. Supervising Controller pattern,
3. Passive View pattern &
4. MVC pattern
Aurelia supports a variety of module loaders. Besides SystemJS, it supports
1. all AMD-based loaders such as RequireJS, Cajon & Dojo
2. module-based build systems like Webpack
Following are the basics used in Aurelia app
1. scripts/system.js:
- a modern JavaScript module loader.
- Aurelia is a modern framework, its written as modules & encourages to create code in a modular fashion. To use modules in ES Next one needs a loader that understands modular code. That's what SystemJS does.
- locates modules, understands their dependencies & ensures that everything is properly loaded at run time
1) import
- SystemJS API
- tells loader to load/import module with specified name
2. config-typscript.js:
- a configuration file for the SystemJS module loader that installs a transpiler into the loader. As a result, each time a module is loaded, its able to take ESNext/TypeScript code & automatically convert it to ES5 code that browsers fully understand.
- In a production app, transpiler is not used to transform code on-the-fly in the browser to avoid its poorly performance since it requires to distribute an entire transpiler with app
3. scripts/aurelia-core.min.js:
- core of Aurelia, in a single script file
- need to add to use framework to enable all capabilites
4. aurelia-bootstrapper:
- resides in aurelia-core.min.js
- contains bootstrap/startup code
- tells Aurelia to load framework, configure it & run app
5. aurelia-app attribute:
- pointing to src/main
- tells Aurelia's bootstrapper what module contains the framework configuration as well as HTML element is the "host" element where the application will be rendered.
6. aurelia.json:
- whenever dependencies are installed, we need to tell Aurelia which application bundle they should be included in & how to properly configure them with the module system.
- Location: aurelia_project -> aurelia.json
- this file contains all the information that the Aurelia CLI uses to build project
- under bundle section of this file, there are two bundles by default
1) app-bundle.js - contains code
2) vendor-bundle.js - contains all 3rd party libraries
- whenever this file changes restart process au run
- under bundle section of this file, there are two bundles by default
1) app-bundle.js - contains code
2) vendor-bundle.js - contains all 3rd party libraries
- whenever this file changes restart process au run
7. TypeScript Definition Files:
- when using 3rd party libraries, in
order to make them work in a TypeScript project, you will either need to
install the d.ts files or create them for yourself.
Comments
Post a Comment