8thwall / web

8th Wall Web projects and resources.
519 stars 326 forks source link

Expose hideLoadingScreen and hideLoadingScreenNow #158

Open f0rr0 opened 3 years ago

f0rr0 commented 3 years ago

Expose hideLoadingScreen and hideLoadingScreenNow to consumers.

Since showLoading mutates DOM, consumers can call these methods to clean up side-effects or bail early from an 8thWall session. For instance if I am inside a SPA and the user decides to exit the 8thwall route before the loading has finished, I would call these methods to cleanup the loading DOM mutations.

jparismorgan commented 3 years ago

Hi @f0rr0, thanks the suggestion! The R17.1 engine release added a new lifecycle event, onRemove, which is called when a pipeline module is removed. Along with that we updated loading-module.js to call hideLoadingScreenNow() in onRemove. This should lead to the loading module cleaning itself up when you exit an 8th Wall experience, which is something it didn't do well before.

Does this solve your issue? With it you shouldn't need to call hideLoadingScreen or hideLoadingScreenNow yourself, instead the pipeline module should clean itself up. If not I'd love to learn more about what's missing for your scenario. Thanks!

https://github.com/8thwall/web/pull/184/files#diff-f408e456fa730f212ad9756d053d59f2e4b9dfc9f5630dd42e7af6ac4dc84081R450