Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,61 @@ These functions, either combine things and produce one thing, or make many thing

In addition to the default layers, Node In Layers allows you to create new layers and place them where you want. Our ONLY requirement, is that default layers that are loaded (services, features, entries) must be above one another. Other than that, you can create layers below, above, or in between these.

## Composite Layers

Layering by its nature is a vertical stack approach. Each layer sits on top of each other, and only has access to what is below it.

However, sometimes there is a need to create a layer via combining multiple smaller layers. This creates a single horizontal layer. We call these composite layers.

#### Vertical Layers

```
[ Layer 1 ]
[ Layer 2 ]
[ Layer 3 ]
```

#### Composite Layers (Horizontal Layers)

```
[ Layer 1 ]
[ Sub-Layer 1 ][ Sub-Layer 2][ Sub-Layer 3]
[ Layer 3 ]
```

This is very easy to accomplish in this package.

## How To Implement Composite Layers

When you create your configuration file you use the `layerOrder` property to identify your layers. You can also add in arrays within this array, that has a list of names. This will load each of those layers and combine them together.

Note: In a standard functional way, the composite layers are loaded one at a time, and only have access to the previous layer information. This is to prevent cyclical references, which are an indication of a design that needs to be reworked. Unlike vertical layers which ONLY have access to what is below it, composite layers have access to everything to the left of them and just below. This will be explained below.

### How Composite Layers Are Loaded And What They Have Access To.

Imagine you have the following system.

```
[ Layer 3 ]
[ Sub-Layer 1 ][ Sub-Layer 2][ Sub-Layer 3]
[ Layer 1 ]
```

There are 3 layers here. 1, 2, and 3.
1 and 3 are normal layers, while layer 2 is a composite layer, composed of 3 composite-layers.

1. Layer 1 is loaded first, then layer 2, and then layer 3.
2. When layer 2 is being loaded it is loaded from left to right.
3. Sub-Layer 1, then Sub-layer 2, then Sub-layer 3.
4. All of layer 2 has access to layer 1. However, the sub layers only have access to the sub-layers that are before it. (But they have access to all of the layers before it).
5. Once layer 2 is finished, layer 3 is loaded, and has access to each of the components of layer 2.

So...

- Sub-Layer 1 only has access to Layer 1
- Sub-Layer 2 has access to Sub-Layer 1 as well as Layer 1
- Sub-Layer 3 has access to Sub-Layers 1 and 2, as well as Layer 1

# Cohesive Layers In Action

Here is an example file breakdown for a coehsive layered ecommerce system that is written in typescript.
Expand Down
Loading