Skip to content

Commit 289bf80

Browse files
committed
Revert "force struct use for messaging fixes #2"
This reverts commit 9842714.
1 parent ef68027 commit 289bf80

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/UnityEventAggregator/EventAggregator.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ public static class EventAggregator
1515
/// </summary>
1616
/// <typeparam name="T">The type of event being listened for.</typeparam>
1717
/// <param name="obj"></param>
18-
public static void Register<T>(this T obj) where T : struct
18+
public static void Register<T>(this object obj)
1919
{
20-
if (!_cache.ContainsKey(typeof(T)))
21-
_cache[typeof(T)] = new List<object>();
22-
20+
if (!_cache.ContainsKey(typeof(T))) _cache[typeof(T)] = new List<object>();
2321
_cache[typeof(T)].Add(obj);
2422
}
2523

@@ -28,7 +26,7 @@ public static void Register<T>(this T obj) where T : struct
2826
/// </summary>
2927
/// <typeparam name="T">The type of event to no longer listen for.</typeparam>
3028
/// <param name="obj"></param>
31-
public static void UnRegister<T>(this T obj) where T : struct
29+
public static void UnRegister<T>(this object obj)
3230
{
3331
if (!_cache.ContainsKey(typeof(T))) return;
3432
_cache[typeof(T)].Remove(obj);
@@ -65,7 +63,7 @@ public static void UnRegister(object obj, Type listener)
6563
/// </summary>
6664
/// <typeparam name="T">The type of event being notified.</typeparam>
6765
/// <param name="message"></param>
68-
public static void SendMessage<T>(T message) where T : struct
66+
public static void SendMessage<T>(T message)
6967
{
7068
_cache[message.GetType()].Each(x => ((IListener<T>)x).Handle(message));
7169
}
@@ -74,7 +72,7 @@ public static void SendMessage<T>(T message) where T : struct
7472
/// Creates the cache for objects that listen to each event
7573
/// </summary>
7674
/// <typeparam name="T">Searches through all active GameObjects for those listening for event T and auto registers them.</typeparam>
77-
public static void UpdateCache<T>() where T : struct
75+
public static void UpdateCache<T>()
7876
{
7977
var type = typeof(IListener<T>);
8078
var list = new List<object>();

src/UnityEventAggregator/IListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace UnityEventAggregator
22
{
3-
public interface IListener<T> where T : struct
3+
public interface IListener<T>
44
{
55
void Handle(T message);
66
}

0 commit comments

Comments
 (0)