About aspects

This tutorial gives an overview of what aspects are, in the context of BladeRunner, and explains how they fit into the application structure.

An aspect is a specific presentation of an app to a user. It might be used in particular circumstances (in the Creating a New Aspect tutorial, there is a detailed example of a Login aspect, which is displayed instead of the main app contents if the user is not logged in), on particular devices (you might need to access the same information and functionality through a completely different interface, depending on whether you are using a PC, a tablet or a smart-phone), or because of different preferences. A single app may have multiple aspects; providing for different devices, user segments and so on. On the other hand, an app might get by perfectly well on just the default-aspect. It all depends on your needs.

In a BladeRunner application, an aspect consists of an entry index.html page, and a set of required resources. It acts as a sub-context for that application. Each aspect potentially has access to all the resources and blades in its parent application, but it may be set up only to deliver a fraction of that to the end-users.

The Basic App Structure

Within the bladerunner directory, your apps folder will contain the root folders of all your apps, plus a folder called WEB-INF. The example below has only one app: myapp. The home directory of each aspect resides in the root of the application that owns it; its name always suffixed with -aspect.

br aspect 1

In the above example, myapp contains a single bladeset (which contains all the blades belonging to the app) and a single aspect: the aptly named default-aspect.

How do Aspects Work with bundlers?

An aspect uses 'seed locations' to determine which of its parent application’s blades and resources it depends upon. These seed locations are made up of the src and resources folders as well as the index.html file within the aspect’s home directory.

br aspect 2

These seed locations are scanned for references to caplin libraries, third-party libraries, bladesets and blades. If any are found, those resources are then pulled in, together with any dependencies that cascade downwards for each bundle resource type.

For instance, you might have some HTML inside the resources folder of your default-aspect, which refers to a blade. BladeRunner will see this and load this blade into your app when the default-aspect is viewed.

You can see all the dependencies for a particular aspect, by running the 'app-dependencies' command:

bladerunner app-dependencies _ _

For example:

bladerunner app-dependencies example-app default

You can find out how to create a new aspect in the Creating a New Aspect tutorial.