WB
Web Bae4w ago
Kudz

How to execute a function after loading multiple libraries

Hey guys! It’s been a while but I need some advice on something. I’m using Google Maps API + Finsweet CMS Load API (render all mode). I’m loading 1000+ items from a CMS Collection then pass all that info into Google Maps API to place markers on a map. My question is, if the Finsweet CMS loads & renders separately from the Google Maps, how can I make my function wait until both of them are fully loaded (plus wait for Finsweet CMS to render all 1000+ items) before running. Currently I’ve got my code running after CMS load because I’m sure in most cases it’ll execute later than Maps but it feels a bit lazy tbh. Also side question, is typescript really THAT good or should I stick to JS. I don’t have any problems with it but I might just be at the top of mount stupid again 🫠🥴
1 Reply
Web Bae
Web Bae2w ago
Hey @Kudz sorry for the delay here. You should be able to delay script execution for CMS Load and Google maps to finish using promises. 1. Load both scripts. 2. Inside the callback for CMS Load renderitems event start setting up your google maps instance. TS is great but it can be annoying at times - need a build step (one day this might not be required) - can sometimes create more work to satisfy the type check for complex types. overall though it has helped me learn to write better code, though these days I find myself doing a lot of JS since its just easier for tutorials and writing simple scripts. I alwyas use TS on personal projects and larger projects, but JS for everything else.
Want results from more Discord servers?
Add your server