Abstract away or eliminate most of the mutation of the Elements array ()

This commit is contained in:
Pete Hunt
2020-03-14 21:48:51 -07:00
committed by GitHub
parent 05af9f04ed
commit e1e2249f57
17 changed files with 293 additions and 272 deletions

@ -1,6 +1,17 @@
import { ExcalidrawElement } from "../element/types";
class SceneState {
constructor(private _elements: readonly ExcalidrawElement[] = []) {}
getAllElements() {
return this._elements;
}
replaceAllElements(nextElements: readonly ExcalidrawElement[]) {
this._elements = nextElements;
}
}
export const createScene = () => {
const elements: readonly ExcalidrawElement[] = [];
return { elements };
return new SceneState();
};