"Request Song List" for Streaming about Dance pads games (stepmania)

Hello,

Newbie here from France, so please forgive my frenglish ! It’s my first time trying to code an extension for Twitch, so I’ve much to learn and am willing to get any constructive guidance.

I’m currently working on an extension that would take an input from the chat, and will display it on an overlay panel on the stream, in order to let the current streamer know what songs/charts are being requested by the viewer.

I’ve came here to ask for a better way to do what I’ve done so far.

So, I’ve managed to get the inputs from the chat, thanks to the chatbot tutorial. I’m sending them to the backend, where I store them in a const array.
Then from the frontend, I’m checking every 10 seconds an update of the requests list, and I find something, I’ll update a panel on the chat.

That’s my way of doing and it works, but I’m wondering if there is a better way to do it ? Like having a passive listener on the frontend that can get notified by the backend only when a request from the chat is sent ?

Thanks for your help,
Chrossowen

You are looking for a PubSub (Publish/Subscribe) solution. Luckily, twitch lets extensions use pubsub.

The frontend will subscribe to song requests, and the backend will publish song requests as they occur.

1 Like

Thank you very much ! Now I remember having heard of this concept, but never actually practice it, this will be a good exercice ! :slight_smile: