Is your feature request related to a problem? Please describe.
I'm working on an Amplify React app that is becoming quite large rather rapidly. Many components must rely on the sceneController returned by the SumerianScene component being valid, i.e. that the scene has loaded and the event broker object has retrieved the sceneController. For instance we have buttons that trigger actions using the sceneController, and these buttons cause the React app to crash if pressed before scene load. For that example, I'd like to be able to disable those buttons until the scene is loaded.
Describe the solution you'd like
A new method:
XR.untilSceneLoaded(sceneConfig) - returns a Promise that resolves when the scene is loaded (resolves instantly if scene is already loaded), or rejects if scene load fails.
The only problem is that this method can only logically be called after XR.loadScene() is called, so it introduces the potential for other race conditions. Maybe resolve this by merging XR.loadScene into untilSceneLoaded such that untilSceneLoaded will attempt a load if one is not in process (the thought process being that we don't care which load command gets to the Sumerian backend first)?
Describe alternatives you've considered
Gratuitious use of setInterval (thereby ruining initial UX) and careful app design to avoid subtle race conditions.
Hey @jkeys-ecg-nmsu,
I think having some way to subscribe to a scene being loaded event it would be useful. I will look into a solution for this.
@jordanranz could you just add special channel(s) to Hub like you all have done for Auth events?
I'm not sure my initial proposal to have a promise that resolves on scene load makes much sense; I thought about it for a bit and figured the only way to implement it would be some sort of exponential backoff algorithm with a receipt system, which if implemented in Hub and not handrolled would definitely takes Hub out of the lightweight category (not necessarily performant though!).
@jordanranz yes, proving subscriptions for async XR events makes sense.
@jkeys-ecg-nmsu,
This feature request will be added to our backlog. Sorry for the delay in response!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.