Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
add missing types
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels-Be committed Mar 20, 2020
1 parent eed0300 commit c4b9845
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions templates/typescript-class.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export class {{className $.name}} extends EventEmitter {
}

// forward all signals
this.on("newListener", (event, listener) => {
this.on("newListener", (event: string, listener: (...args: any[]) => void) => {
if(event === "PropertiesChanged" && this.listenerCount('PropertiesChanged') === 0) {
this.propertiesDBusInterface.on('PropertiesChanged', forwardPropertyChange);
} else {
this.thisDBusInterface.on(event, listener);
}
});
this.on("removeListener", (event, listener) => {
this.on("removeListener", (event: string, listener: (...args: any[]) => void) => {
if(event === "PropertiesChanged" && this.listenerCount('PropertiesChanged') === 0) {
this.propertiesDBusInterface.removeListener('PropertiesChanged', forwardPropertyChange);
} else {
Expand All @@ -75,7 +75,7 @@ export class {{className $.name}} extends EventEmitter {
{{#each property}}
//@property({ name: '{{$.name}}', signature: '{{$.type}}', access: {{accessConst $.access}} }){{#ifeq $.access "read"}}
public {{$.name}}(): Promise<{{tsType $.type}}> {
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}};
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant: DBus.Variant) => variant.value){{/unlesseq}};
}{{/ifeq}}{{#ifeq $.access "write"}}
public {{$.name}}(value: {{tsType $.type}}): Promise<void> {
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}});
Expand All @@ -86,7 +86,7 @@ export class {{className $.name}} extends EventEmitter {
if(value !== undefined) {
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}});
} else {
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}};
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant: DBus.Variant) => variant.value){{/unlesseq}};
}
}{{/ifeq}}

Expand Down
6 changes: 4 additions & 2 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ declare module 'dbus-next' {
export class Variant<T = any> {
signature: string;
value: T;
constructor();
constructor(signatur: string, value: T);
}
export class DBusError extends Error {
type: string;
Expand Down Expand Up @@ -96,8 +98,7 @@ declare module 'dbus-next' {
}

export class MessageBus {
getProxyObject(name: string, path: string): Promise<ProxyObject>;
getProxyObject(name: string, path: string, xml: string): Promise<ProxyObject>;
getProxyObject(name: string, path: string, xml?: string): Promise<ProxyObject>;
disconnect(): void;

export(path: ObjectPath, interface: interface.Interface): void;
Expand Down Expand Up @@ -133,6 +134,7 @@ declare module 'dbus-next' {
busAddress?: string;
}

export function setBigIntCompat(state: boolean): void;
export function systemBus(): MessageBus;
export function sessionBus(options?: BusOptions): MessageBus;
}

0 comments on commit c4b9845

Please sign in to comment.