Skip to content

Commit

Permalink
Use locks instead of readyToProceed, see phetsims/tambo#126
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jan 25, 2021
1 parent 6270e6d commit 9898532
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/simLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if ( Tandem.PHET_IO_ENABLED ) {
} );
}

const unlockLaunch = asyncLoader.createLock( { name: 'launch' } );

class SimLauncher {
constructor() {

Expand All @@ -42,7 +44,8 @@ class SimLauncher {
launch( callback ) {
assert && assert( !window.phet.joist.launchCalled, 'Tried to launch twice' );

asyncLoader.readyToProceed( () => {
// Add listener before unlocking the launch lock
asyncLoader.addListener( () => {

window.phet.joist.launchSimulation = () => {
assert && assert( !this.launchComplete, 'should not have completed launching the sim yet' );
Expand Down Expand Up @@ -79,6 +82,7 @@ class SimLauncher {
window.phet.joist.launchSimulation();
}
} );
unlockLaunch();

// Signify that the simLauncher was called, see https://github.com/phetsims/joist/issues/142
window.phet.joist.launchCalled = true;
Expand Down

0 comments on commit 9898532

Please sign in to comment.