Skip to content

Commit

Permalink
Add state to state-changed event args
Browse files Browse the repository at this point in the history
For subscribers, prevent having to invoke getWindowById and getState by including in event arguments

Fixes morganstanley#255
  • Loading branch information
bingenito committed Jun 17, 2019
1 parent 93953f5 commit 83c6bfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions packages/desktopjs-electron/src/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import {
registerContainer, ContainerWindow, PersistedWindowLayout, Rectangle, Container, WebContainerBase,
ScreenManager, Display, Point, ObjectTransform, PropertyMap, NotificationOptions, ContainerNotification,
TrayIconDetails, MenuItem, Guid, MessageBus, MessageBusSubscription, MessageBusOptions, GlobalShortcutManager
TrayIconDetails, MenuItem, Guid, MessageBus, MessageBusSubscription, MessageBusOptions, GlobalShortcutManager,
EventArgs, WindowEventArgs
} from "@morgan-stanley/desktopjs";

registerContainer("Electron", {
Expand Down Expand Up @@ -208,8 +209,8 @@ export class ElectronContainerWindow extends ContainerWindow {
: Promise.resolve();

return promise.then(() => {
this.emit("state-changed", { name: "state-changed", sender: this });
ContainerWindow.emit("state-changed", { name: "state-changed", windowId: this.id } );
this.emit("state-changed", <EventArgs> { name: "state-changed", sender: this, state: state });
ContainerWindow.emit("state-changed", <WindowEventArgs> { name: "state-changed", windowId: this.id, state: state } );
});
}

Expand Down
6 changes: 3 additions & 3 deletions packages/desktopjs-openfin/src/openfin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
registerContainer, ContainerWindow, PersistedWindowLayout, Rectangle, Container, WebContainerBase,
ScreenManager, Display, Point, ObjectTransform, PropertyMap, NotificationOptions, ContainerNotification,
TrayIconDetails, MenuItem, Guid, MessageBus, MessageBusSubscription, MessageBusOptions, EventArgs,
GlobalShortcutManager
GlobalShortcutManager, WindowEventArgs
} from "@morgan-stanley/desktopjs";

registerContainer("OpenFin", {
Expand Down Expand Up @@ -188,8 +188,8 @@ export class OpenFinContainerWindow extends ContainerWindow {

resolve();
}).then(() => {
this.emit("state-changed", { name: "state-changed", sender: this });
ContainerWindow.emit("state-changed", { name: "state-changed", windowId: this.id } );
this.emit("state-changed", <EventArgs> { name: "state-changed", sender: this, state: state });
ContainerWindow.emit("state-changed", <WindowEventArgs> { name: "state-changed", windowId: this.id, state: state } );
});
}

Expand Down
7 changes: 4 additions & 3 deletions packages/desktopjs/src/Default/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
*/

import { Container, WebContainerBase } from "../container";
import { ContainerWindow, PersistedWindowLayout, Rectangle } from "../window";
import { ContainerWindow, PersistedWindowLayout, Rectangle, WindowEventArgs } from "../window";
import { ScreenManager, Display, Point } from "../screen";
import { NotificationOptions } from "../notification";
import { ObjectTransform, PropertyMap } from "../propertymapping";
import { Guid } from "../guid";
import { MessageBus, MessageBusSubscription, MessageBusOptions } from "../ipc";
import { EventArgs } from "../events";

declare var Notification: any;

Expand Down Expand Up @@ -126,8 +127,8 @@ export namespace Default {

resolve();
}).then(() => {
this.emit("state-changed", { name: "state-changed", sender: this });
ContainerWindow.emit("state-changed", { name: "state-changed", windowId: this.id } );
this.emit("state-changed", <EventArgs> { name: "state-changed", sender: this, state: state });
ContainerWindow.emit("state-changed", <WindowEventArgs> { name: "state-changed", windowId: this.id, state: state } );
});
}

Expand Down

0 comments on commit 83c6bfe

Please sign in to comment.