@@ -15,28 +15,30 @@ The returned web worker runs it's own angular context which allows it to resolve
15
15
16
16
install with bower using:
17
17
18
+ ```bash
18
19
bower install angular-workers
20
+ ```
19
21
20
22
##How to use
21
23
22
24
* Depend on the WorkerService.
23
25
* Specify the URL to the file containing the angular script by invoking:
24
26
25
-
27
+ ``` javascript
26
28
// The URL must be absolute because of the URL blob specification
27
29
WorkerService .setAngularUrl (url)
28
-
30
+ ```
29
31
30
32
* OPTIONALLY : Specify how the web worker is to find any dependencies by invoking:
31
33
32
-
34
+ ` ` ` javascript
33
35
// The URL must be absolute because of the URL blob specification
34
36
WorkerService.addDependency(serviceName, moduleName, url)
35
-
37
+ ` ` `
36
38
37
39
* Create create a promise of an angularWorker by invoking:
38
40
39
-
41
+ ` ` ` javascript
40
42
var workerPromise = WorkerService.createAngularWorker(['input', 'output' /*additional optional deps*/,
41
43
function(input, output /*additional optional deps*/) {
42
44
// This contains the worker body.
@@ -54,11 +56,11 @@ install with bower using:
54
56
// worker are propagates to the main thread. Workers run in fully isolated
55
57
// contexts. All communication must be performed through the output parameter.
56
58
}]);
57
-
59
+ ` ` `
58
60
59
61
* When the workerPromise resolves the worker is initialized with it' s own angular context and is ready to use. Like so:
60
62
61
-
63
+ ```javascript
62
64
workerPromise.then(function success(angularWorker) {
63
65
//The input must be serializable
64
66
return angularWorker.run(inputObject);
@@ -71,8 +73,8 @@ install with bower using:
71
73
//handle error
72
74
}, function notify(update) {
73
75
//handle update
74
- });
75
-
76
+ });
77
+ ```
76
78
77
79
The same initialized worker can be used many times with different input.
78
80
0 commit comments