Added a simple method for subscribing to events.
This commit is contained in:
@@ -37,7 +37,7 @@ namespace TwitchChatTTS.Bus
|
||||
{
|
||||
if (!_topics.TryGetValue(topic, out var bus))
|
||||
{
|
||||
bus = new ServiceBusObservable(topic, this);
|
||||
bus = new ServiceBusObservable(topic, this, _logger);
|
||||
_topics.Add(topic, bus);
|
||||
}
|
||||
return bus;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Reactive;
|
||||
using Serilog;
|
||||
|
||||
namespace TwitchChatTTS.Bus
|
||||
{
|
||||
@@ -6,11 +7,13 @@ namespace TwitchChatTTS.Bus
|
||||
{
|
||||
private readonly string _topic;
|
||||
private readonly ServiceBusCentral _central;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ServiceBusObservable(string topic, ServiceBusCentral central)
|
||||
public ServiceBusObservable(string topic, ServiceBusCentral central, ILogger logger)
|
||||
{
|
||||
_topic = topic;
|
||||
_central = central;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override IDisposable SubscribeCore(IObserver<ServiceBusData> observer)
|
||||
@@ -19,6 +22,10 @@ namespace TwitchChatTTS.Bus
|
||||
return new ServiceBusUnsubscriber(_topic, _central, observer);
|
||||
}
|
||||
|
||||
public IDisposable Subscribe(Action<ServiceBusData> action) {
|
||||
return Subscribe(new ServiceBusObserver(action, _logger));
|
||||
}
|
||||
|
||||
private sealed class ServiceBusUnsubscriber : IDisposable
|
||||
{
|
||||
private readonly string _topic;
|
||||
|
Reference in New Issue
Block a user