Abstract away or eliminate most of the mutation of the Elements array (#955)
This commit is contained in:
@ -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();
|
||||
};
|
||||
|
Reference in New Issue
Block a user