Skip to content

Commit d78f0f1

Browse files
committed
Add return self to service_interface
This patch add a 'return self;' to each functions in service_interface module to use method chaining technique. This helps developers write code more conveniently. Please refer to the example below. var obj = service.createObject('/test'); obj.createInterface('test.iface') .addMethod('method1', ...) .addMethod('method2', ...) .update(); Signed-off-by: Inho Oh <[email protected]>
1 parent c700929 commit d78f0f1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/service_interface.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ ServiceInterface.prototype.addMethod = function(method, opts, handler) {
4040
}
4141

4242
self.methods[method] = methodObj;
43+
44+
return self;
4345
};
4446

4547
ServiceInterface.prototype.addProperty = function(propName, opts) {
@@ -58,6 +60,8 @@ ServiceInterface.prototype.addProperty = function(propName, opts) {
5860
}
5961

6062
self.properties[propName] = propObj;
63+
64+
return self;
6165
};
6266

6367
ServiceInterface.prototype.addSignal = function(signalName, opts) {
@@ -72,6 +76,8 @@ ServiceInterface.prototype.addSignal = function(signalName, opts) {
7276
var args = [ signalName ].concat(Array.prototype.slice.call(arguments));
7377
self.emitSignal.apply(this, args);
7478
});
79+
80+
return self;
7581
};
7682

7783
ServiceInterface.prototype.call = function(method, message, args) {
@@ -200,6 +206,8 @@ ServiceInterface.prototype.emitSignal = function() {
200206
}
201207

202208
self.object.service.bus._dbus.emitSignal(conn, objPath, interfaceName, signalName, args, signatures);
209+
210+
return self;
203211
};
204212

205213
ServiceInterface.prototype.update = function() {
@@ -264,4 +272,6 @@ ServiceInterface.prototype.update = function() {
264272
introspection.push('</interface>');
265273

266274
self.introspection = introspection.join('\n');
275+
276+
return self;
267277
};

0 commit comments

Comments
 (0)