(hoofbeats) Fixes some anonymous closures and gets scanning working.
[profile/ivi/cowhide.git] / examples / hoofbeats / javascripts / app / store.js
1 /* vi: set et sw=4 ts=4 si: */
2 (function(app) {
3     var Store = function() {
4         this.reset();
5         this.scan();
6     }
7
8     Store.prototype = {
9         reset: function() {
10             this.scanCompleted = false;
11         },
12
13         scan: function() {
14             var self = this;
15
16             if (self.scanCompleted) {
17                 return;
18             }
19
20             if (app.library) {
21                 app.library.scan().then(function() {
22                     self.scanCompleted = true;
23                 });
24             } else {
25                 setTimeout(function() {
26                     self.scan();
27                 }, 100);
28             }
29         },
30
31         getArtists: function() {
32             var artists = [];
33             return artists;
34         }
35     };
36
37     app.Store = new Store();
38 })(window.Hoofbeats);