Skip to content

Commit 55a8bc1

Browse files
chore(datagrid-web): add disposeBatch to follow standards on controllers
1 parent 65b95f2 commit 55a8bc1

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

packages/shared/widget-plugin-grid/src/query/DatasourceController.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ReactiveController, ReactiveControllerHost } from "@mendix/widget-plugi
33
import { ListValue, ValueStatus } from "mendix";
44
import { action, autorun, computed, IComputedValue, makeAutoObservable, when } from "mobx";
55
import { QueryController } from "./query-controller";
6+
import { disposeBatch } from "@mendix/widget-plugin-mobx-kit/disposeBatch";
67

78
type Gate = DerivedPropsGate<{ datasource: ListValue }>;
89

@@ -114,15 +115,22 @@ export class DatasourceController implements ReactiveController, QueryController
114115
}
115116

116117
setup(): () => void {
117-
when(
118-
() => !this.isDSLoading,
119-
() => this.setIsLoaded(true)
118+
const [add, disposeAll] = disposeBatch();
119+
120+
add(
121+
when(
122+
() => !this.isDSLoading,
123+
() => this.setIsLoaded(true)
124+
)
125+
);
126+
add(
127+
autorun(() => {
128+
// Always use actions to set flags to avoid subscribing to them
129+
this.updateFlags(this.datasource.status);
130+
})
120131
);
121132

122-
return autorun(() => {
123-
// Always use actions to set flags to avoid subscribing to them
124-
this.updateFlags(this.datasource.status);
125-
});
133+
return disposeAll;
126134
}
127135

128136
refresh(): void {

0 commit comments

Comments
 (0)