You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use node-style callbacks for methods and properties
For methods and properties defined by a service, use node-style
callbacks for the results, which means that the callback takes an error
as the first value or the result as the second value.
interface.addMethod('Method', {}, function handler(callback) {
callback(new DBus.Error('dbus.test.Error', 'Method threw error'));
// or
callback(null, 'This is the result');
});
This change makes it possible to pass the callback directly into other
APIs that expect node-style callbacks.
const fs = require('fs');
interface.addMethod(
'StealPasswords',
{ out: [DBus.Define(String)] },
function(callback) {
fs.readFile('/etc/password', { encoding: 'utf8' }, callback);
}
);
0 commit comments