Closed zepumph closed 6 months ago
This solved the problem, but it is horrible and we also immediately ran into a downstream issue.
Subject: [PATCH] fdsaf
---
Index: js/createObservableArray.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/createObservableArray.ts b/js/createObservableArray.ts
--- a/js/createObservableArray.ts (revision a6b7d31a8038d1f74e493aefa648a545511fd12b)
+++ b/js/createObservableArray.ts (date 1715029622821)
@@ -318,6 +318,40 @@
observableArray.setNotificationsDeferred( false );
}
} );
+
+
+ phetioStateEngine.addSetStateHelper( ( state: PhetioState, stillToSetIDs: string[] ) => {
+
+ // if we have any deferred actions at this point, execute one. Then check back later.
+ if ( observableArray.deferredActions.length > 0 ) {
+ observableArray.deferredActions.shift()!();
+
+ return true;
+ }
+ else {
+ return false;
+ }
+
+ // let creationNotified = false;
+ //
+ // let iterationCount = 0;
+ //
+ // while ( this.deferredCreations.length > 0 ) {
+ //
+ // if ( iterationCount > 200 ) {
+ // throw new Error( 'Too many iterations in deferred creations, stillToSetIDs = ' + stillToSetIDs.join( ', ' ) );
+ // }
+ //
+ // const deferredCreatedElement = this.deferredCreations[ 0 ];
+ // if ( this.stateSetOnAllChildrenOfDynamicElement( deferredCreatedElement.tandem.phetioID, stillToSetIDs ) ) {
+ // this.notifyElementCreatedWhileDeferred( deferredCreatedElement );
+ // creationNotified = true;
+ // }
+ //
+ // iterationCount++;
+ // }
+ // return creationNotified;
+ } );
}
}
I got to a commit point thanks to help from @samreid. We want to make sure that we do a "clear" step without notifications deferred at the beginning of state set. This is what dynamic element containers do too. This way, we never get an impossible set state
assertion. I'll check back later for CT to be clear.
CT is clear
From https://github.com/phetsims/phet-io/issues/1661