Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: polyfill event emitter for property inspector #24

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/actions/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onDialDown<T extends api.PayloadObject<T> = object>(listener: (ev: DialDownEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("dialDown", (ev: api.DialDown<T>) => listener(new ActionEvent<api.DialDown<T>>(new Action<T>(this.connection, ev), ev)));
return this.connection.disposableOn("dialDown", (ev: api.DialDown<T>) => listener(new ActionEvent<api.DialDown<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand All @@ -79,7 +79,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onDialRotate<T extends api.PayloadObject<T> = object>(listener: (ev: DialRotateEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("dialRotate", (ev: api.DialRotate<T>) => listener(new ActionEvent<api.DialRotate<T>>(new Action<T>(this.connection, ev), ev)));
return this.connection.disposableOn("dialRotate", (ev: api.DialRotate<T>) => listener(new ActionEvent<api.DialRotate<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand All @@ -91,7 +91,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onDialUp<T extends api.PayloadObject<T> = object>(listener: (ev: DialUpEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("dialUp", (ev: api.DialUp<T>) => listener(new ActionEvent<api.DialUp<T>>(new Action<T>(this.connection, ev), ev)));
return this.connection.disposableOn("dialUp", (ev: api.DialUp<T>) => listener(new ActionEvent<api.DialUp<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand All @@ -103,7 +103,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onKeyDown<T extends api.PayloadObject<T> = object>(listener: (ev: KeyDownEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("keyDown", (ev: api.KeyDown<T>) => listener(new ActionEvent<api.KeyDown<T>>(new Action<T>(this.connection, ev), ev)));
return this.connection.disposableOn("keyDown", (ev: api.KeyDown<T>) => listener(new ActionEvent<api.KeyDown<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand All @@ -115,7 +115,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onKeyUp<T extends api.PayloadObject<T> = object>(listener: (ev: KeyUpEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("keyUp", (ev: api.KeyUp<T>) => listener(new ActionEvent<api.KeyUp<T>>(new Action<T>(this.connection, ev), ev)));
return this.connection.disposableOn("keyUp", (ev: api.KeyUp<T>) => listener(new ActionEvent<api.KeyUp<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand All @@ -125,7 +125,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onTitleParametersDidChange<T extends api.PayloadObject<T> = object>(listener: (ev: TitleParametersDidChangeEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("titleParametersDidChange", (ev: api.TitleParametersDidChange<T>) =>
return this.connection.disposableOn("titleParametersDidChange", (ev: api.TitleParametersDidChange<T>) =>
listener(new ActionEvent<api.TitleParametersDidChange<T>>(new Action<T>(this.connection, ev), ev))
);
}
Expand All @@ -137,7 +137,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onTouchTap<TSettings extends api.PayloadObject<TSettings> = object>(listener: (ev: TouchTapEvent<TSettings>) => void): IDisposable {
return this.connection.addDisposableListener("touchTap", (ev: api.TouchTap<TSettings>) =>
return this.connection.disposableOn("touchTap", (ev: api.TouchTap<TSettings>) =>
listener(new ActionEvent<api.TouchTap<TSettings>>(new Action<TSettings>(this.connection, ev), ev))
);
}
Expand All @@ -150,7 +150,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onWillAppear<T extends api.PayloadObject<T> = object>(listener: (ev: WillAppearEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("willAppear", (ev: api.WillAppear<T>) => listener(new ActionEvent<api.WillAppear<T>>(new Action<T>(this.connection, ev), ev)));
return this.connection.disposableOn("willAppear", (ev: api.WillAppear<T>) => listener(new ActionEvent<api.WillAppear<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand All @@ -161,9 +161,7 @@ export class ActionClient {
* @returns A disposable that, when disposed, removes the listener.
*/
public onWillDisappear<T extends api.PayloadObject<T> = object>(listener: (ev: WillDisappearEvent<T>) => void): IDisposable {
return this.connection.addDisposableListener("willDisappear", (ev: api.WillDisappear<T>) =>
listener(new ActionEvent<api.WillDisappear<T>>(new Action<T>(this.connection, ev), ev))
);
return this.connection.disposableOn("willDisappear", (ev: api.WillDisappear<T>) => listener(new ActionEvent<api.WillDisappear<T>>(new Action<T>(this.connection, ev), ev)));
}

/**
Expand Down
Loading