summaryrefslogtreecommitdiffstats
path: root/js/build/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/build/app.js')
-rw-r--r--js/build/app.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/js/build/app.js b/js/build/app.js
index 8c5835c06..3a72dc277 100644
--- a/js/build/app.js
+++ b/js/build/app.js
@@ -38,8 +38,19 @@ app.run([
'$location',
'Loading',
'Setup',
- function ($rootScope, $location, Loading, Setup) {
+ 'Item',
+ 'Feed',
+ 'Folder',
+ 'Publisher',
+ 'Settings',
+ function ($rootScope, $location, Loading, Setup, Item, Feed, Folder, Publisher, Settings) {
'use strict';
+ // listen to keys in returned queries to automatically distribute the
+ // incoming values to models
+ Publisher.subscribe(Item).toChannel('items');
+ Publisher.subscribe(Folder).toChannel('folders');
+ Publisher.subscribe(Feed).toChannel('feeds');
+ Publisher.subscribe(Settings).toChannel('settings');
// load feeds, settings and last read feed
Setup.load();
$rootScope.$on('$routeChangeStart', function () {
@@ -175,23 +186,16 @@ app.service('Publisher', function () {
}
};
};
- this.publishAll = function (values) {
- var key;
- for (key in values) {
- if (values.hasOwnProperty(key)) {
- this.publish(values[key]).onChannel(key);
+ this.publishAll = function (data) {
+ var channel, counter;
+ for (channel in data) {
+ if (data.hasOwnProperty(channel)) {
+ for (counter = 0; counter < this.channels[channel].length; counter += 1) {
+ this.channels[channel][counter].receive(data[channel]);
+ }
}
}
};
- this.publish = function (value) {
- return {
- onChannel: function (channel) {
- self.channels[channel].forEach(function (object) {
- object.receive(value);
- });
- }
- };
- };
});
app.service('Setup', function () {
'use strict';