Skip to content

Commit 4798442

Browse files
committed
Introduce & Implement data monitoring contracts
1 parent d57dbd7 commit 4798442

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using RealTimeWeatherMonitoringApp.Domain.Common;
2+
3+
namespace RealTimeWeatherMonitoringApp.Application.Interfaces;
4+
5+
/// <summary>
6+
/// Notifies subscribers about changes in data of type <typeparamref name="TObserved"/>.
7+
/// </summary>
8+
/// <typeparam name="TObserved">The observed data type.</typeparam>
9+
public interface IDataChangeNotifier<TObserved>
10+
{
11+
event EventHandler<DataChangeEventArgs<TObserved>> OnDataChange;
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace RealTimeWeatherMonitoringApp.Application.Interfaces;
2+
3+
/// <summary>
4+
/// Defines the ability to receive data of type <typeparamref name="TReceived"/>.
5+
/// </summary>
6+
/// <typeparam name="TReceived">The received data type.</typeparam>
7+
public interface IDataReceiver<in TReceived>
8+
{
9+
void Receive(TReceived data);
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using RealTimeWeatherMonitoringApp.Application.Interfaces;
2+
using RealTimeWeatherMonitoringApp.Domain.Common;
3+
4+
namespace RealTimeWeatherMonitoringApp.Application.Service;
5+
6+
public class MonitoringService<TData> : IDataReceiver<TData>, IDataChangeNotifier<TData>
7+
{
8+
public void Receive(TData data) =>
9+
OnDataChange?.Invoke(this, new DataChangeEventArgs<TData>(data));
10+
11+
public event EventHandler<DataChangeEventArgs<TData>>? OnDataChange;
12+
}

0 commit comments

Comments
 (0)