Skip to content
Snippets Groups Projects
Commit 93ea759a authored by Alexander Rose's avatar Alexander Rose
Browse files

StateTreeSpine.current tweaks

parent 3e50377e
No related branches found
No related tags found
No related merge requests found
......@@ -162,7 +162,7 @@ class State {
return cell && cell.obj;
}
} finally {
this.spine.setCurrent();
this.spine.current = undefined;
if (updated) this.events.changed.next();
this.events.isUpdating.next(false);
......@@ -607,7 +607,7 @@ async function updateNode(ctx: UpdateContext, currentRef: Ref): Promise<UpdateNo
throw new Error(`No suitable parent found for '${currentRef}'`);
}
ctx.spine.setCurrent(current);
ctx.spine.current = current;
const parent = parentCell.obj!;
current.sourceRef = parentCell.transform.ref;
......
......@@ -18,14 +18,14 @@ interface StateTreeSpine {
namespace StateTreeSpine {
export class Impl implements StateTreeSpine {
private current: StateObjectCell | undefined = void 0;
setCurrent(cell?: StateObjectCell) {
this.current = cell;
}
private _current: StateObjectCell | undefined = void 0;
get current() { return this._current; }
set current(cell: StateObjectCell | undefined) { this._current = cell; }
getAncestorOfType<T extends StateObject.Ctor>(t: T): StateObject.From<T> | undefined {
if (!this.current) return void 0;
let cell = this.current;
if (!this._current) return void 0;
let cell = this._current;
while (true) {
cell = this.cells.get(cell.transform.parent)!;
if (!cell.obj) return void 0;
......@@ -35,8 +35,8 @@ namespace StateTreeSpine {
}
getRootOfType<T extends StateObject.Ctor>(t: T): StateObject.From<T> | undefined {
if (!this.current) return void 0;
let cell = this.current;
if (!this._current) return void 0;
let cell = this._current;
let ret: StateObjectCell | undefined = void 0;
while (true) {
cell = this.cells.get(cell.transform.parent)!;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment