doceazedo / emotettv

💬 A Twitch (BTTV, FFZ & 7TV) emotes and badges parser - built with TMI.js in mind
https://emotettv.gitbook.io
18 stars 1 forks source link

Ability to preload emote cache from object #19

Open tadev opened 1 week ago

tadev commented 1 week ago

Hey, thank you for this library - currently experimenting with it and found that page load times are really slow because emotettv has to reload all the emotes every time the page is loaded. It would be incredibly helpful if the emote parser offered a function to export and import cached emotes per channel, this way emotes could be cached on the server side while still benefitting from the incredible performance of your parser. Do you have any clues on how to implement this?

doceazedo commented 1 week ago

Hi! I really like your suggestion :) For starters, we would need to add an export() function to EmotesParser. We can also add an optional data parameter to EmotesLoader (or something similar). From there, we can create exportEmotes() and exportBadges(). It might also be useful to add an event dispatcher to track when the emote/badge data changes...

Once these are implemented in emotettv, you could fetch the emotes using exportEmotes() (or when the event is triggered), save them wherever you want, and then pass the exported data to reloadEmotes(...) later on. Would this work for you?

I might have some time to implement this over the next few days or if you want to submit a PR yourself, feel free to do so!!