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

Debounce invalidations #68

Merged
merged 2 commits into from
Nov 27, 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
5 changes: 5 additions & 0 deletions .changeset/swift-vans-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@projectstorm/react-workspaces-core': minor
---

Add debounce to layout invalidations
14 changes: 7 additions & 7 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"storybook:build": "storybook build -o .out"
},
"dependencies": {
"@emotion/styled": "^11.13.0",
"@emotion/styled": "^11.13.5",
"@projectstorm/react-workspaces-behavior-divider-dropzone": "workspace:*",
"@projectstorm/react-workspaces-behavior-panel-dropzone": "workspace:*",
"@projectstorm/react-workspaces-behavior-resize": "workspace:*",
Expand All @@ -26,19 +26,19 @@
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/addon-essentials": "^8.4.1",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addons": "^7.6.17",
"@storybook/react": "^8.4.1",
"@storybook/react-webpack5": "^8.4.1",
"@storybook/react": "^8.4.5",
"@storybook/react-webpack5": "^8.4.5",
"@storybook/storybook-deployer": "^2.8.16",
"@storybook/theming": "^8.4.1",
"@storybook/theming": "^8.4.5",
"@types/lodash": "^4.17.13",
"@types/node": "^22.8.6",
"@types/node": "^22.10.0",
"@types/react": "18.3.12",
"@types/react-dom": "^18.3.1",
"react-dom": "18.3.1",
"source-map-loader": "^5.0.0",
"storybook": "^8.4.1",
"storybook": "^8.4.5",
"webpack": "^5.96.1"
}
}
4 changes: 2 additions & 2 deletions example-project-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"@projectstorm/react-workspaces-behavior-resize": "workspace:*",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"@babel/core": "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3",
"prettier": "^3.4.1",
"typescript": "^5.7.2",
"terser-webpack-plugin": "^5.3.10",
"@changesets/cli": "^2.27.9",
"@changesets/cli": "^2.27.10",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-node-externals": "^3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/behavior-divider-dropzone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"react": "^18.3.1",
"@emotion/styled": "^11.13.0"
"@emotion/styled": "^11.13.5"
},
"devDependencies": {
"@types/react": "^18.3.12"
Expand Down
6 changes: 3 additions & 3 deletions packages/behavior-panel-dropzone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
},
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/free-solid-svg-icons": "^6.7.1",
"@fortawesome/react-fontawesome": "^0.2.2",
"@fortawesome/fontawesome-svg-core": "^6.6.0",
"@fortawesome/fontawesome-svg-core": "^6.7.1",
"react": "^18.3.1",
"lodash": "^4.17.21",
"@emotion/styled": "^11.13.0"
"@emotion/styled": "^11.13.5"
},
"devDependencies": {
"@types/lodash": "^4.17.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/behavior-resize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"react": "^18.3.1",
"@emotion/styled": "^11.13.0"
"@emotion/styled": "^11.13.5"
},
"devDependencies": {
"@types/react": "^18.3.12"
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@emotion/styled": "^11.13.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.5",
"@emotion/react": "^11.13.5",
"lodash": "^4.17.21",
"color": "^4.2.3",
"uuid": "^11.0.2"
"uuid": "^11.0.3"
},
"devDependencies": {
"@types/react": "^18.3.12",
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/core/WorkspaceEngine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class WorkspaceEngine extends BaseObserver<WorkspaceEngineListener> imple
this.rootModelListener?.();
this.rootModelListener = model.registerListener({
layoutInvalidated: () => {
this.invalidateLayout();
this.invalidateLayoutDebounced();
},
dimensionsInvalidated: () => {
this.invalidateDimensionsDebounced();
Expand All @@ -78,6 +78,10 @@ export class WorkspaceEngine extends BaseObserver<WorkspaceEngineListener> imple
this.iterateListeners((cb) => cb.layoutInvalidated?.());
}

invalidateLayoutDebounced = _.debounce(() => {
this.invalidateLayout();
}, 200);

invalidateDimensionsDebounced = _.debounce(() => {
this.invalidateDimensions();
}, 200);
Expand Down
8 changes: 4 additions & 4 deletions packages/defaults/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
},
"dependencies": {
"react": "^18.3.1",
"@emotion/styled": "^11.13.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.5",
"@emotion/react": "^11.13.5",
"lodash": "^4.17.21",
"@projectstorm/react-workspaces-core": "workspace:*",
"@projectstorm/react-workspaces-model-tabs": "workspace:*",
"@projectstorm/react-workspaces-model-tray": "workspace:*",
"@projectstorm/react-workspaces-model-floating-window": "workspace:*",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/free-solid-svg-icons": "^6.7.1",
"@fortawesome/react-fontawesome": "^0.2.2",
"@fortawesome/fontawesome-svg-core": "^6.6.0"
"@fortawesome/fontawesome-svg-core": "^6.7.1"
},
"devDependencies": {
"@types/react": "^18.3.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/dropzone-plugin-tabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@projectstorm/react-workspaces-core": "workspace:*",
"@projectstorm/react-workspaces-model-tabs": "workspace:*",
"@projectstorm/react-workspaces-behavior-panel-dropzone": "workspace:*",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/fontawesome-svg-core": "^6.6.0"
"@fortawesome/free-solid-svg-icons": "^6.7.1",
"@fortawesome/fontawesome-svg-core": "^6.7.1"
},
"devDependencies": {
"@types/react": "^18.3.12"
Expand Down
4 changes: 2 additions & 2 deletions packages/dropzone-plugin-tray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@projectstorm/react-workspaces-core": "workspace:*",
"@projectstorm/react-workspaces-model-tray": "workspace:*",
"@projectstorm/react-workspaces-behavior-panel-dropzone": "workspace:*",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/fontawesome-svg-core": "^6.6.0"
"@fortawesome/free-solid-svg-icons": "^6.7.1",
"@fortawesome/fontawesome-svg-core": "^6.7.1"
},
"devDependencies": {
"@types/react": "^18.3.12"
Expand Down
6 changes: 3 additions & 3 deletions packages/model-floating-window/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@fortawesome/free-solid-svg-icons": "^6.7.1",
"@fortawesome/react-fontawesome": "^0.2.2",
"@fortawesome/fontawesome-svg-core": "^6.6.0",
"@fortawesome/fontawesome-svg-core": "^6.7.1",
"react": "^18.3.1",
"@emotion/styled": "^11.13.0"
"@emotion/styled": "^11.13.5"
},
"devDependencies": {
"@types/react": "^18.3.12"
Expand Down
4 changes: 2 additions & 2 deletions packages/model-tabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"react": "^18.3.1",
"@emotion/styled": "^11.13.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.5",
"@emotion/react": "^11.13.5",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/model-tray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@projectstorm/react-workspaces-core": "workspace:*",
"@projectstorm/react-workspaces-model-floating-window": "workspace:*",
"@emotion/styled": "^11.13.0",
"@emotion/styled": "^11.13.5",
"react": "^18.3.1",
"lodash": "^4.17.21"
},
Expand Down
Loading
Loading