I am using Shopify App Bridge to embed my app in the Shopify admin with the App Bridge Navigation bar. I have spend days trying to work out how to add a loading indicator between pages as it currently loads but the previous page is still there until the next page is ready to be displayed and there is no indication of loading. Is there a simple fix for this as I have little understanding of javascript and have a working app using flask and python but can’t understand what I need to add to my html templates to get it working.
I have tried the Shopify docs, most specifically - https://shopify.dev/tools/app-bridge/actions/loading
I added the following in the head of the html templates:
<script src="https://unpkg.com/@shopify/app-bridge@1.10.1/umd/index.js"></script>
and in the body of the html templates:
<script type="text/javascript">
import createApp from '@shopify/app-bridge';
import {Loading} from '@shopify/app-bridge/actions';
const app = createApp({
apiKey: '12345',
shopOrigin: shopOrigin,
});
const loading = Loading.create(app);
</script>
I have added my apiKey and shopOrigin base domain directly just to test, but I am unsure if this is what I need to do and if so what else do I need to add for the loading part.
It seems that I might need to add this, but not sure where or what I need to Do when loading starts.
loading.subscribe(Loading.Action.START, () => {
// Do something when loading starts
});
Any help or pointers would be greatly appreciated, thanks.