Skip to content

Commit 0aef570

Browse files
Update README.md
1 parent 7fc0c59 commit 0aef570

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,30 @@ The returned web worker runs it's own angular context which allows it to resolve
1515

1616
install with bower using:
1717

18+
```bash
1819
bower install angular-workers
20+
```
1921

2022
##How to use
2123

2224
* Depend on the WorkerService.
2325
* Specify the URL to the file containing the angular script by invoking:
2426

25-
27+
```javascript
2628
// The URL must be absolute because of the URL blob specification
2729
WorkerService.setAngularUrl(url)
28-
30+
```
2931

3032
* OPTIONALLY: Specify how the web worker is to find any dependencies by invoking:
3133

32-
34+
```javascript
3335
// The URL must be absolute because of the URL blob specification
3436
WorkerService.addDependency(serviceName, moduleName, url)
35-
37+
```
3638

3739
* Create create a promise of an angularWorker by invoking:
3840

39-
41+
```javascript
4042
var workerPromise = WorkerService.createAngularWorker(['input', 'output' /*additional optional deps*/,
4143
function(input, output /*additional optional deps*/) {
4244
// This contains the worker body.
@@ -54,11 +56,11 @@ install with bower using:
5456
// worker are propagates to the main thread. Workers run in fully isolated
5557
// contexts. All communication must be performed through the output parameter.
5658
}]);
57-
59+
```
5860

5961
* When the workerPromise resolves the worker is initialized with it's own angular context and is ready to use. Like so:
6062
61-
63+
```javascript
6264
workerPromise.then(function success(angularWorker) {
6365
//The input must be serializable
6466
return angularWorker.run(inputObject);
@@ -71,8 +73,8 @@ install with bower using:
7173
//handle error
7274
}, function notify(update) {
7375
//handle update
74-
});
75-
76+
});
77+
```
7678
7779
The same initialized worker can be used many times with different input.
7880

0 commit comments

Comments
 (0)