Edge function experiment: "Heal the broken heart!"
Web developer hearts broke when they saw problems with serverless functions: cold starts and network latency caused by their functions being deployed to a single region. 😞
But alas, edge functions were created to (hopefully) save the day!
Edge functions run on an edge network, which is a bit like a CDN for serverless functions (except the runtime is more limited so you can't just deploy any serverless function to the edge).
Let's test-out the latency and cold-start aspect of an edge network function and get this heart healed! Heal the heart by moving it out of the game board one step at a time.
With each move, this app will simultenously execute 2 types of moves:
- A "local move" heart that moves immediately (with a paper-trail effect).
- A round-trip network-move heart that moves once its network call returns.I also added an animation to this move so you can more-easily see it "flow onto" the spot of the local-move heart.
You'll be able to visually see the difference between these two types. Hopefully the edge function proves more responsive than the serverless function!
DEVELOPER TIP: Open up the console to see some valuable info printed as you make moves or change network settings.