The Data module is a reusable AngularJS module used to access Buildbot's data API from the browser. Its main purpose is to handle the 3 way binding.
2 way binding is the angular MVVM concept, which seamlessly synchronise the view and the model. Here, we introduce an additional way of synchronisation, which is from the server to the model.
- blockdiag {
View <- Model <- Server;
}
We use the message queue and the websocket interfaces to maintain synchronisation between the server and the client.
The client application just needs to query the needed data using a highlevel API, and the data module uses the best approach to make the data always up to date.
Once the binding is set up by the controller, everything is automatically up to date.
All the data you can get are Collections. Even a query to a single resource returns a collection. A collection is an Array subclass which has extra capabilities:
- It listens to the event stream and is able to maintain itself up-to-date
- It implements client side queries in order to guarantee up-to-date filtering, ordering and limiting queries.
- It has a fast access to each item it contains via its id.
- It has its own event handlers so that the client code can react when the Collection is changing
Each data type contained in a collection is wrapped in a javascript object. This allows to create some custom enhancements to the data model. For example, the Change wrapper decodes the author name and email from the "author" field.
Each wrapper class also has specific access methods, which allow to access more data from the REST hierarchy.
- blockdiag {
data.getBuilds -> Collection -> Builds -> b.getSteps -> Collection -> Steps;
}
The Data module is available as a standalone AngularJS module.
Installation via yarn:
yarn add buildbot-data
Inject the bbData
module to your application:
angular.module('myApp', ['bbData'])