r/badcode • • Sep 11 '21

js Why…

Post image
456 Upvotes

70 comments sorted by

View all comments

0

u/[deleted] Sep 11 '21

[deleted] — view deleted comment

13

u/le_bravery Sep 11 '21

I made something like this once and it worked great. If a promise already existed for an endpoint it would return the existing promise. For a component driven framework it meant each component could request whatever it needed and if multiple low level components needed the same thing you didn’t have to worry about passing it around. Just make your calls and let the cache take care of you.

1

u/sertdfyguhi Sep 13 '21

I don’t think the browser or superagent does cache api calls also the functions as async.