using System; namespace Unity.BossRoom.Infrastructure { public class BufferedMessageChannel : MessageChannel, IBufferedMessageChannel { public override void Publish(T message) { HasBufferedMessage = true; BufferedMessage = message; base.Publish(message); } public override IDisposable Subscribe(Action handler) { var subscription = base.Subscribe(handler); if (HasBufferedMessage) { handler?.Invoke(BufferedMessage); } return subscription; } public bool HasBufferedMessage { get; private set; } = false; public T BufferedMessage { get; private set; } } }