-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPublisher.cs
More file actions
31 lines (25 loc) · 1.05 KB
/
IPublisher.cs
File metadata and controls
31 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace GofPatterns.Behavioral.ObserverPattern;
/// <summary>
/// Publisher (or Broadcaster) interface.
/// Publishers are responsible for managing subscribers and notifying them of events.
/// </summary>
/// <typeparam name="TInput"></typeparam>
public interface IPublisher<TInput>
{
public void AddSubscriber(ISubscriber<TInput> subscriber);
public void RemoveSubscribers();
public void NotifySubscribers(TInput input);
}
/// <summary>
/// Publisher (or Broadcaster) interface.
/// Publishers are responsible for managing subscribers and notifying them of events.
/// Multiple subscribers can be subscribed to a category, and there can be multiple categories.
/// </summary>
/// <typeparam name="TInput"></typeparam>
/// <typeparam name="TCategory"></typeparam>
public interface IPublisher<TInput, in TCategory> where TCategory : notnull
{
public void AddSubscriber(ISubscriber<TInput> subscriber, TCategory category);
public void RemoveSubscribers(TCategory category);
public void NotifySubscribers(TInput input, TCategory category);
}