Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
1.0 KiB

// ==========================================================================
// DefaultEventNotifier.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
namespace Squidex.Infrastructure.CQRS.Events
{
public sealed class DefaultEventNotifier : IEventNotifier
{
private static readonly string ChannelName = typeof(DefaultEventNotifier).Name;
private readonly IPubSub pubsub;
public DefaultEventNotifier(IPubSub pubsub)
{
Guard.NotNull(pubsub, nameof(pubsub));
this.pubsub = pubsub;
}
public void NotifyEventsStored(string streamName)
{
pubsub.Publish(ChannelName, streamName, true);
}
public IDisposable Subscribe(Action<string> handler)
{
return pubsub.Subscribe(ChannelName, x => handler?.Invoke(x));
}
}
}