Removed messages from TTSPublisher
This commit is contained in:
parent
f47685a17d
commit
fe2eb86a08
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user