Skip to content

Commit ce2075a

Browse files
committed
Cleaning Code
1 parent e26334d commit ce2075a

File tree

1 file changed

+24
-49
lines changed

1 file changed

+24
-49
lines changed

example/app.js

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Main module of the application.
1010
*/
1111
var app = angular
12-
.module('angular-workers-example', ['FredrikSandell.worker-pool'])
12+
.module('angular-workers-example', ['FredrikSandell.worker-pool'])
1313
.run(function (WorkerService) {
1414
//WorkerService.setAngularUrl('../bower_components/angular/angular.js');
1515
WorkerService.setAngularUrl('https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js');
@@ -28,91 +28,66 @@ app.controller("myChartCtrl", function($scope,WorkerService) {
2828
$scope.data.reply3 = 'c';
2929

3030
$scope.test = function (arg) {
31-
31+
3232
/**
33-
// This contains the worker body.
34-
// The function must be self contained.
35-
// The function body will be converted to source and passed to the worker.
33+
// This contains the worker body.
34+
// The function must be self contained.
35+
// The function body will be converted to source and passed to the worker.
3636
// The input parameter is what will be passed to the worker when it is executed. It must be a serializable object.
3737
// The output parameter is a promise and is what the worker will return to the main thread.
3838
// All communication from the worker to the main thread is performed by resolving, rejecting or notifying the output promise.
3939
// We may optionally depend on other angular services. These services can be used just as in the main thread.
4040
// But be aware that no state changes in the angular services in the worker are propagates to the main thread. Workers run in fully isolated contexts.
41-
// All communication must be performed through the output parameter.
41+
// All communication must be performed through the output parameter.
4242
*/
4343
var workerPromise = WorkerService.createAngularWorker(['input', 'output', '$http', function (input, output, $http) {
44-
44+
4545
var i=0;
46-
46+
4747
var callback = function(i) {
4848
output.notify(i);
4949
i++;
5050
};
51-
51+
5252

5353
//for (var i = 0; i < 10; i++) { callback(i); }
5454
//var intervalID = setInterval(callback(i), 3000);
5555
setInterval(function(){ callback(++i); }, Math.floor((Math.random() * 1000) + 100));
56-
56+
5757
//output.resolve(true);
5858
//output.reject(false);
59-
59+
6060
}]);
6161

6262
workerPromise
63-
.then(function success(angularWorker) {
64-
//The input must be serializable
63+
.then(function success(angularWorker) {
64+
//The input must be serializable
6565
return angularWorker.run($scope.awesomeThings);
6666
}, function error(reason) {
67-
67+
6868
console.log('callback error');
6969
console.log(reason);
70-
71-
//for some reason the worker failed to initialize
72-
//not all browsers support the HTML5 tech that is required, see below.
70+
71+
//for some reason the worker failed to initialize
72+
//not all browsers support the HTML5 tech that is required, see below.
7373
}).then(function success(result) {
74-
74+
7575
console.log('success');
7676
console.log(result);
77-
78-
//handle result
77+
78+
//handle result
7979
}, function error(reason) {
8080
//handle error
8181
console.log('error');
8282
console.log(reason);
83-
83+
8484
}, function notify(update) {
8585
//handle update
86-
87-
$scope.data['reply' + arg] += update + '\n';
86+
87+
$scope.data['reply' + arg] += update + '\n';
8888
//console.log(arg);
89-
//console.log(update);
89+
//console.log(update);
9090
});
9191

9292
};
93-
94-
95-
});
96-
97-
98-
/*
99-
100-
var app = angular.module("myApp", ['nvd3ChartDirectives']);
101-
102-
app.controller("myChartCtrl", function($scope,$http) {
103-
104-
$scope.data = {};
105-
$scope.data.bar = [];
106-
107-
/*
108-
$http.get('http://localhost:8080/data?type=cheese').
109-
success(function(data, status, headers, config) {
110-
$scope.data.bar = data;
111-
}).
112-
error(function(data, status, headers, config) {
113-
console.log('error');
114-
$scope.bar = [];
115-
});
116-
11793
});
118-
*/

0 commit comments

Comments
 (0)