Class: Interface

interface~Interface()

The Interface is an abstract class used for defining and exporting an interface on a DBus name. You can override this class to make your own DBus interfaces. Use the decorators within this module to define the properties, methods, and signals that the interface has. These will be advertised to users in the introspection xml gotten by the org.freedesktop.DBus.Introspect method on the name. See the documentation for the decorators for more information. The constructor of the Interface should call super() with the name of the interface that will be exported.

Constructor

new Interface()

Create an interface. This should be called with the name of the interface in the class that extends it.

Source:
Example
class MyInterface extends Interface {
   constructor() {
     super('org.test.interface_name');
   }
   // define properties, methods, and signals with decorated functions
}
let bus = dbus.sessionBus();
let name = await bus.requestName('org.test.bus_name');
let iface = new MyInterface();
name.export('/org/test/path', iface);

Methods

(static) configureMembers(members)

An alternative to the decorator functions to configure Interface DBus members when decorators cannot be supported.

Calling this method twice on the same Interface or mixing this method with the decorator interface will result in undefined behavior that may be specified at a future time.

Parameters:
Name Type Description
members Object

Member configuration object.

Properties
Name Type Description
properties Object

The class methods to define as properties. The key should be a method defined on the class and the value should be the options for a property decorator.

methods Object

The class methods to define as DBus methods. The key should be a method defined on the class and the value should be the options for a method decorator.

signals Object

The class methods to define as signals. The key should be a method defined on the class and hte value should be options for a signal decorator.

Source:
Example
ConfiguredInterface.configureMembers({
  properties: {
    SomeProperty: {
      signature: 's'
    }
  },
  methods: {
    Echo: {
      inSignature: 'v',
      outSignature: 'v'
    }
  },
  signals: {
    HelloWorld: {
      signature: 'ss'
    }
  }
});

(static) emitPropertiesChanged(iface, changedProperties, invalidatedProperties)

Emit the PropertiesChanged signal on an Interfaces associated standard org.freedesktop.DBus.Properties interface with a map of new values and invalidated properties. Pass the properties as JavaScript values.

Parameters:
Name Type Description
iface module:interface~Interface

the Interface to emit the PropertiesChanged signal on

changedProperties Object

A map of property names and new property values that are changed.

invalidatedProperties Array.<string>

A list of invalidated properties.

Source:
Example
Interface.emitPropertiesChanged({ SomeProperty: 'bar' }, ['InvalidedProperty']);