Removed messages from TTSPublisher

This commit is contained in:
Tom 2024-11-08 15:26:10 +00:00
parent f47685a17d
commit fe2eb86a08

View File

@ -5,24 +5,17 @@ namespace TwitchChatTTS.Chat.Observers
public class TTSPublisher : IObservable<TTSGroupedMessage>
{
private readonly HashSet<IObserver<TTSGroupedMessage>> _observers;
private readonly HashSet<TTSGroupedMessage> _messages;
public TTSPublisher()
{
_observers = new();
_messages = new();
}
public IDisposable Subscribe(IObserver<TTSGroupedMessage> observer)
{
if (_observers.Add(observer))
{
foreach (var item in _messages)
observer.OnNext(item);
}
_observers.Add(observer);
return new Unsubscriber<TTSGroupedMessage>(_observers, observer);
}
}