wip
This commit is contained in:
29
stores/componentStore.ts
Normal file
29
stores/componentStore.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { DraggablePropsType } from "@/components/Draggable/Draggable";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
class ComponentsStore {
|
||||
components:DraggablePropsType[] = [];
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
initComponent(componentsList:DraggablePropsType[]) {
|
||||
this.components = componentsList || [];
|
||||
}
|
||||
|
||||
changeComponent(componentsList:DraggablePropsType) {
|
||||
this.components = this.components.map(item => {
|
||||
if (item.id !== componentsList.id) {
|
||||
return item;
|
||||
}
|
||||
return componentsList;
|
||||
})
|
||||
}
|
||||
|
||||
delectComponent(componentsList:DraggablePropsType) {
|
||||
this.components = this.components.filter(item => item.id !== componentsList.id);
|
||||
}
|
||||
}
|
||||
|
||||
export default new ComponentsStore();
|
||||
Reference in New Issue
Block a user