Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "comments"

This reverts commit f8fb4d5.
  • Loading branch information...
commit 7a699714ca5b117b5813fb91010a1179750c0c70 1 parent f8fb4d5
@wiill authored
View
50 app/App.MockedStatisticsService.js
@@ -1,28 +1,24 @@
-(function(App){
-
- /**
- * MockedStatisticService definition
- */
- App.MockedStatisticService = function(){
- var self = {};
- var defaultStatistic = {
- ToursTotal: 505,
- ToursRunning: 110,
- ToursCompleted: 115
- };
- var currentStatistic = $.extend({}, defaultStatistic);
-
- self.mockStatistic = function(statistics){
- currentStatistic = $.extend({}, defaultStatistic, statistics);
- };
-
- self.getStatistics = function(){
- var asyncSubject = new Rx.AsyncSubject();
- asyncSubject.OnNext(currentStatistic);
- asyncSubject.OnCompleted();
- return asyncSubject.AsObservable();
- };
-
- return self;
- };
+(function(App){
+ App.MockedStatisticService = function(){
+ var self = {},
+ defaultStatistic = {
+ ToursTotal: 505,
+ ToursRunning: 110,
+ ToursCompleted: 115
+ },
+ currentStatistic = $.extend({}, defaultStatistic);;
+
+ self.mockStatistic = function(statistics){
+ currentStatistic = $.extend({}, defaultStatistic, statistics);
+ };
+
+ self.getStatistics = function(){
+ var asyncSubject = new Rx.AsyncSubject();
+ asyncSubject.OnNext(currentStatistic);
+ asyncSubject.OnCompleted();
+ return asyncSubject.AsObservable();
+ };
+
+ return self;
+ };
})(App)
View
71 app/App.ViewModels.HomeScreenViewModel.js
@@ -1,46 +1,25 @@
-/**
- * ViewModel namespace init
- */
-(function(App){
- /**
- * HomeScreenViewModel definition
- * @param service
- */
- App.ViewModels.HomeScreenViewModel = function(service){
- var self = {};
- var disposableServicePoller = Rx.Disposable.Empty;
-
- self.toursTotal = ko.observable(0);
- self.toursRunning = ko.observable(0);
- self.toursCompleted = ko.observable(0);
- self.toursAvailable = ko.dependentObservable(function(){return this.toursTotal() > 0; }, self);
-
- self.showTourList = function(){
- $.mobile.changePage('#tourlist', 'pop', false, true);
- };
-
- self.startServicePolling = function(){
- disposableServicePoller = Rx.Observable
- .Interval(10000)
- .Select(service.getStatistics)
- .Switch()
- .Subscribe(function(statistics){
- self.toursTotal(statistics.ToursTotal);
- self.toursRunning(statistics.ToursRunning);
- self.toursCompleted(statistics.ToursCompleted);
- });
- };
-
- self.stopServicePolling = disposableServicePoller.Dispose;
-
- return self;
- };
-
- /**
- * AnotherViewModel definition
- * @param service
- */
- App.ViewModels.AnotherViewModel = function(service){
-
- }
-})(App);
+(function(App){
+ App.ViewModels.HomeScreenViewModel = function(service){
+ var self = {}, disposableServicePoller = Rx.Disposable.Empty;
+
+ self.toursTotal = ko.observable(0);
+ self.toursRunning = ko.observable(0);
+ self.toursCompleted = ko.observable(0);
+ self.toursAvailable = ko.dependentObservable(function(){ return this.toursTotal() > 0; }, self);
+ self.showTourList = function(){ $.mobile.changePage('#tourlist', 'pop', false, true); };
+ self.startServicePolling = function(){
+ disposableServicePoller = Rx.Observable
+ .Interval(10000)
+ .Select(service.getStatistics)
+ .Switch()
+ .Subscribe(function(statistics){
+ self.toursTotal(statistics.ToursTotal);
+ self.toursRunning(statistics.ToursRunning);
+ self.toursCompleted(statistics.ToursCompleted);
+ });
+ };
+ self.stopServicePolling = disposableServicePoller.Dispose;
+
+ return self;
+ };
+})(App)
View
36 app/App.js
@@ -1,25 +1,13 @@
-var App = window.App = {};
-
-// ViewModels namespace definition
-App.ViewModels = {};
-
-
-$(document).bind('mobileinit', function(){
- // while app is running use App.Service.mockStatistic({ToursCompleted: 45}); to fake backend data from the console
-
- //create application scope service
- var service = App.Service = new App.MockedStatisticService();
-
- //when page in created in JQM...
- $('#home').live('pagecreate', function(event, ui){
-
- //... create HomeScreenViewModel using created service...
- var viewModel = new App.ViewModels.HomeScreenViewModel(service);
-
- //... databind...
- ko.applyBindings(viewModel, this);
-
- //... and start VM operations
- viewModel.startServicePolling();
- });
+var App = window.App = {};
+App.ViewModels = {};
+
+$(document).bind('mobileinit', function(){
+ // while app is running use App.Service.mockStatistic({ToursCompleted: 45}); to fake backend data from the console
+ var service = App.Service = new App.MockedStatisticService();
+
+ $('#home').live('pagecreate', function(event, ui){
+ var viewModel = new App.ViewModels.HomeScreenViewModel(service);
+ ko.applyBindings(viewModel, this);
+ viewModel.startServicePolling();
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.