-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Review code, modular code structure
- Loading branch information
1 parent
9ff3c39
commit cb8b5c8
Showing
6 changed files
with
79 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/lb-components/src/store/toolConfig/baseToolConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { StateCreator } from 'zustand'; | ||
import { BaseStore } from './types'; | ||
|
||
const baseToolStateCreator: StateCreator<BaseStore> = (set, get) => ({ | ||
onlyLoadFirstData: false, | ||
setOnlyLoadFirstData: (onlyLoadFirstData) => set((state) => ({ onlyLoadFirstData })), | ||
}); | ||
|
||
export default baseToolStateCreator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { create } from 'zustand'; | ||
import { ToolConfigStore } from './types'; | ||
import baseToolStateCreator from './baseToolConfig'; | ||
import pointCloudToolStateCreator from './pointCloudToolConfig'; | ||
|
||
interface toolConfigStore { | ||
onlyLoadFirstData: boolean; | ||
selectBoxVisibleSwitch: boolean; | ||
setOnlyLoadFirstData: (onlyLoadFirstData: boolean) => void; | ||
setSelectBoxVisibleSwitch: (selectBoxVisibleSwitch: boolean) => void; | ||
} | ||
|
||
const useToolConfigStore = create<toolConfigStore>((set) => ({ | ||
onlyLoadFirstData: false, | ||
selectBoxVisibleSwitch: false, | ||
setOnlyLoadFirstData: (onlyLoadFirstData) => set((state) => ({ onlyLoadFirstData })), | ||
setSelectBoxVisibleSwitch: (selectBoxVisibleSwitch) => | ||
set((state) => ({ selectBoxVisibleSwitch })), | ||
const useToolConfigStore = create<ToolConfigStore>((set, get, api) => ({ | ||
...baseToolStateCreator(set, get, api), | ||
...pointCloudToolStateCreator(set, get, api), | ||
})); | ||
|
||
export default useToolConfigStore; |
10 changes: 10 additions & 0 deletions
10
packages/lb-components/src/store/toolConfig/pointCloudToolConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { StateCreator } from 'zustand'; | ||
import { PointCloudToolConfigStore } from './types'; | ||
|
||
const pointCloudToolStateCreator: StateCreator<PointCloudToolConfigStore> = (set, get) => ({ | ||
selectBoxVisibleSwitch: false, | ||
setSelectBoxVisibleSwitch: (selectBoxVisibleSwitch: boolean) => | ||
set(() => ({ selectBoxVisibleSwitch })), | ||
}); | ||
|
||
export default pointCloudToolStateCreator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Define basic generic types that will be used by all state modules | ||
export interface BaseStore { | ||
onlyLoadFirstData: boolean; | ||
setOnlyLoadFirstData: (onlyLoadFirstData: boolean) => void; | ||
} | ||
|
||
// Define point cloud type: PointCloudToolConfig Store | ||
export interface PointCloudToolConfigStore { | ||
selectBoxVisibleSwitch: boolean; | ||
setSelectBoxVisibleSwitch: (selectBoxVisibleSwitch: boolean) => void; | ||
} | ||
|
||
// Import all types into toolConfig Store through inheritance | ||
export interface ToolConfigStore extends BaseStore, PointCloudToolConfigStore {} |