소스 검색

StateTreeSpine.current tweaks

Alexander Rose 5 년 전
부모
커밋
93ea759a71
2개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제
  1. 2 2
      src/mol-state/state.ts
  2. 8 8
      src/mol-state/tree/spine.ts

+ 2 - 2
src/mol-state/state.ts

@@ -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;

+ 8 - 8
src/mol-state/tree/spine.ts

@@ -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)!;