Skip to content
Ionut Moraru edited this page Mar 14, 2015 · 6 revisions

The DataStore is a service responsible with calling the proper resources and return the response based on topics.

It implements a caching mechanism to avoid making multiple calls to an endpoint in a short period of time. The caching logic takes into account the stale configuration value of a module.

DataStore Diagram

Example (get the outputs for all buildings in a facility):

var facility_id = 1,
  dataStore = $injector.get('dataStore');

dataStore.get('service:facilities/id:' + facility_id + '/controller:buildings',
  function(data) {
    var buildings = data.data;

    _.each(buildings, function(building) {
      dataStore.get('service:buildings/id:' + building.id + '/controller:outputs',
        function(data) {
          var outputs = data.data;

          // use outputs
        }
      );
    });
  }
);

More documentation can be found in the source code.

Clone this wiki locally