What are layers?
One feature that Axiom Stack has that many other web application frameworks do not is the notion of layering. Layers here mean different levels of view on your content. For instance, you can change the contents of an object on one layer and the data wont be affected on others. So it makes staging and previewing content changes incredibly simple.How it works!
Layers operate by publishing changes to the specified layer. For instance, lets say you decided to view a layer. You go to preview.domain.com which you've specified links to the first layer (we'll get into how in a bit). As of now there are no changes to the data. This means that you are effectively looking at the exact site that exists. So, lets assume that you have a home, section, and page. There are no modifications to any of those objects. That means that if you go to preview.domain.com/home you are looking at the same thing someone going to www.domain.com/home is looking at. An analogy that helps is thinking of this like a glass ceiling. A layer can see the objects under itself.Now you decide to make some edits. The domain you are using to access your web app is preview.domain.com. Let's say that you've changed some of the data represented on section, you've persisted a change to section prime (not to be mistaken with Optimus Prime). This change can now be viewed by going to preview.domain.com/home/section.
To be clear here, when you make a change to section on the layer, you're creating section prime. This is a full copy of the object, but does not include children.So, the changes that we just made are now within the first layer. This means that anyone going to preview.domain.com will be able to see the changes I've made on section.
How Does This Help You?
To start with, this helps because you only have to setup DNS entries to make your layers accessible. But, should you desire more, you can do more.Axiom Stack provides API level access to this functionality. The benefit of this API is that as a developer you get the ability to control objects, within different layers, from the Javascript code.
API Overview
The API mentioned above are pretty simple. In all of these cases, the second parameter described is optional. It allows you to specify the layer on which to do the operations. If no layer is specified then it will make a judgment call on the layer to perform the action.- app.getDraft - This method takes at least one parameter, the object you want the draft of. A second parameter can be passed in, this is the number of the layer from which you want the draft. Ultimately, an AxiomObject is returned to you. If the object doesn't already exist on the layer you're requesting from, it will create a new object.
- app.saveDraft - This method takes at least one parameter, the draft object you want to save. A second parameter can be passed in, this is the number of the layer where you want to save the draft.
- app.deleteDraft - This method takes at least one parameter, the object you want to delete. A second parameter can be passed in, this is the number of the layer where you want to delete the object.

