Top

Helpers

On top of Javascript Oriented Object concepts, Aria Templates also provides you methods through helpers to achieve all the most common and repetitive tasks that you will have to face everyday.

Some of them are directly bundled within the Core layer of the framework. The other one are available in the aria.utils package, ready for you to use them as a dependency inside your classes

Here is a non exhaustive list of what is available:

Let's focus in this article on the 2 most important one, or at least, the 2 one you will have to use daily

Ajax Helper

The Ajax Helper is one of the helpers which is directly embedded inside the Core Layer. It's available for you to use through the aria.core.IO singleton class.

You can easily declare and execute an XHR call in your class within just a few lines of code.

The usage of this helper is mainly described in the Working in an Asynchronous World article. If not already done, we strongly encouraged you to read it.

JSON Helper

Working with Aria Templates means to manipulate a lot of JSON objects, and various data. This utility helper is designed to help you manage these sometimes complex manipulations.

Using this helper, you basically can:

  • Performs some tests over your objects, like checking whether this object contains this key with contains(), or testing if a particular node is a metadata node with isMetadata(). You can also create a fresh new clone of an existing object using copy()
  • Apply the Observable pattern to any node of any of your Json object. What does it mean exactly ? It means that you can add listeners to your Json objects in order to be called back anytime a change is done to your data.

Again, as you can see, the second argument of the aria.utils.Json.addListener() method is an Aria Templates callback object. Once inside your callback, you will be provided as argument an object that contains few properties:

  • dataHolder: the object containing the property that has been changed
  • dataName: the property name on the object
  • oldValue: the previous value
  • newValue: the new value