Skip to content

Commit 305fad1

Browse files
author
Owen Barnes
committed
Merge pull request socketstream#343 from brunocoelho/cosmetic
Cosmetic changes to doc
2 parents 4984fd2 + ee89195 commit 305fad1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

doc/guide/en/rpc_responder.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The `products.js` file should contain the available actions as so:
1818

1919
``` javascript
2020
// server/rpc/products.js
21-
exports.actions = function(req, res, ss){
21+
exports.actions = function(req, res, ss) {
2222

2323
return {
2424

@@ -27,7 +27,7 @@ exports.actions = function(req, res, ss){
2727
}
2828

2929
}
30-
}
30+
};
3131
```
3232

3333
### Sending Arguments
@@ -36,7 +36,7 @@ The RPC Responder can take and return unlimited arguments intuitively. For examp
3636

3737
``` javascript
3838
// server/rpc/products.js
39-
exports.actions = function(req, res, ss){
39+
exports.actions = function(req, res, ss) {
4040

4141
return {
4242

@@ -50,7 +50,7 @@ exports.actions = function(req, res, ss){
5050
}
5151

5252
}
53-
}
53+
};
5454
```
5555

5656
To call this from the browser we'd use:
@@ -61,15 +61,17 @@ var productType = 'electronics';
6161
ss.rpc('products.topSelling', '2012-01-01', '2012-01-31', productType, function(products, bestSalesperson) {
6262
console.log('The top selling products in ' + productType + ' were:', products);
6363
console.log('And the best salesperson was:', bestSalesperson);
64-
})
64+
});
6565
```
6666

6767
The ability to pass multiple arguments also means you can choose to follow the 'error first' idiom typically used in Node:
6868

6969
``` javascript
7070
// client/code/main/products.js
71-
ss.rpc('products.add', 123, function(err, data){
72-
if (err) return alert("Error adding product!");
71+
ss.rpc('products.add', 123, function(err, data) {
72+
if (err) {
73+
return alert("Error adding product!");
74+
}
7375
$('#products').append( ss.tmpl['product.details'].render(data) );
7476
});
7577
```
@@ -112,32 +114,32 @@ If you have business logic that you'd like to share between both the client and
112114
myModule = function() {
113115

114116
sharedFunction: function() {
115-
return "shared function called"
117+
return "shared function called";
116118
}
117119

118-
}
120+
};
119121

120-
exports.myModule = myModule()
122+
exports.myModule = myModule();
121123
```
122124

123125
```javascript
124126
// in /app.js
125127

126-
myModule = require('myModule').myModule()
128+
myModule = require('myModule').myModule();
127129

128-
myModule.sharedFunction() // returns "shared function called"
130+
myModule.sharedFunction(); // returns "shared function called"
129131
```
130132

131133
```javascript
132134
// in /rpc/demo.js
133135

134-
myModule = require('myModule').myModule()
136+
myModule = require('myModule').myModule();
135137

136138
exports.actions = function(req, res, ss) {
137139

138140
callSharedFunction: function() {
139-
myModule.sharedFunction() // returns "shared function called"
141+
myModule.sharedFunction(); // returns "shared function called"
140142
}
141143

142144
};
143-
```
145+
```

0 commit comments

Comments
 (0)