Skip to content

Commit 08122aa

Browse files
committed
bug: setup onDidAcitvePanelChange subscription quicker
1 parent ca09ae5 commit 08122aa

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

packages/dockview-core/src/api/dockviewGroupPanelApi.ts

+1-17
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5050
readonly onDidLocationChange: Event<DockviewGroupPanelFloatingChangeEvent> =
5151
this._onDidLocationChange.event;
5252

53-
private readonly _onDidActivePanelChange =
54-
new Emitter<DockviewGroupChangeEvent>();
53+
readonly _onDidActivePanelChange = new Emitter<DockviewGroupChangeEvent>();
5554
readonly onDidActivePanelChange = this._onDidActivePanelChange.event;
5655

5756
get location(): DockviewGroupLocation {
@@ -140,21 +139,6 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
140139
}
141140

142141
initialize(group: DockviewGroupPanel): void {
143-
/**
144-
* TODO: Annoying initialization order caveat, find a better way to initialize and avoid needing null checks
145-
*
146-
* Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
147-
* By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
148-
* finished ensuring the `model` is defined.
149-
*/
150-
151142
this._group = group;
152-
153-
queueMicrotask(() => {
154-
this._mutableDisposable.value =
155-
this._group!.model.onDidActivePanelChange((event) => {
156-
this._onDidActivePanelChange.fire(event);
157-
});
158-
});
159143
}
160144
}

packages/dockview-core/src/dockview/dockviewGroupPanel.ts

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ export class DockviewGroupPanel
124124
options,
125125
this
126126
);
127+
128+
this.addDisposables(
129+
this.model.onDidActivePanelChange((event) => {
130+
this.api._onDidActivePanelChange.fire(event);
131+
})
132+
);
127133
}
128134

129135
override focus(): void {

0 commit comments

Comments
 (0)