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();