Skip to content

Commit

Permalink
chore: use ESNext support for Disposable (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhess authored May 4, 2024
2 parents d617124 + c094094 commit 66d3b07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 54 deletions.
45 changes: 0 additions & 45 deletions src/components/TreeReactFlow/dispose.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/TreeReactFlow/layoutTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const layoutTree = <
const [treeTidy0, nodeInfos, edgeInfos] = primerToTidy(primerTree);
const treeTidy = layout.set_root(treeTidy0);
layout.layout(true);
layout.dispose();
layout[Symbol.dispose]();
const nodeMap = makeNodeMap(
nodeInfos,
edgeInfos,
Expand Down
13 changes: 5 additions & 8 deletions src/components/TreeReactFlow/tidy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
Tidy as TidyWasm,
WasmLayoutType as LayoutType,
} from "@hackworthltd/tidyt-wasm";
import { Disposable } from "./dispose";

export { LayoutType };

Expand Down Expand Up @@ -73,7 +72,7 @@ const NULL_ID = () => {
}
return nullId;
};
export class TidyLayout extends Disposable {
export class TidyLayout implements Disposable {
private tidy: TidyWasm;
private nextId = 1;
private root: InnerNode | undefined;
Expand All @@ -91,7 +90,6 @@ export class TidyLayout extends Disposable {
parent_child_margin: number,
peer_margin: number
) {
super();
if (type === LayoutType.Basic) {
this.tidy = TidyWasm.with_basic_layout(parent_child_margin, peer_margin);
} else if (type === LayoutType.Tidy) {
Expand All @@ -101,11 +99,10 @@ export class TidyLayout extends Disposable {
} else {
throw new Error("not implemented");
}
this._register({
dispose: () => {
this.tidy.free();
},
});
}

[Symbol.dispose]() {
this.tidy.free();
}

changeLayoutType(type: LayoutType) {
Expand Down

0 comments on commit 66d3b07

Please sign in to comment.