mirror of https://github.com/Squidex/squidex.git
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.1 KiB
36 lines
1.1 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 invalidator;
|
|
|
|
public DefaultEventNotifier(IPubSub invalidator)
|
|
{
|
|
Guard.NotNull(invalidator, nameof(invalidator));
|
|
|
|
this.invalidator = invalidator;
|
|
}
|
|
|
|
public void NotifyEventsStored()
|
|
{
|
|
invalidator.Publish(ChannelName, string.Empty, true);
|
|
}
|
|
|
|
public IDisposable Subscribe(Action handler)
|
|
{
|
|
return invalidator.Subscribe(ChannelName, x => handler());
|
|
}
|
|
}
|
|
}
|
|
|