Skip to content

Commit 30e238c

Browse files
authored
Merge pull request #5 from Thundernerd/develop
Develop
2 parents f1dcb22 + adffa47 commit 30e238c

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [1.2.0] - 2020-09-02
4+
5+
### Updated
6+
- When invoking a copy of the subscriptions is made to allow for modifying the original subscriptions without exceptions
7+
38
## [1.1.2] - 2020-08-23
49

510
### Added

Runtime/SafeEvent.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ public void Invoke()
1919
{
2020
if (subscriptions == null)
2121
return;
22-
23-
foreach (Action subscription in subscriptions)
22+
23+
HashSet<Action> subscriptionsCopy = new HashSet<Action>(subscriptions);
24+
25+
foreach (Action subscription in subscriptionsCopy)
2426
{
2527
#if UNITY_EDITOR || DEBUG
2628
ThrowIfInvalidSubscription(subscription);

Runtime/SafeEventOneParameter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public void Invoke(T obj)
2020
if (subscriptions == null)
2121
return;
2222

23-
foreach (Action<T> subscription in subscriptions)
23+
HashSet<Action<T>> subscriptionsCopy = new HashSet<Action<T>>(subscriptions);
24+
25+
foreach (Action<T> subscription in subscriptionsCopy)
2426
{
2527
#if UNITY_EDITOR || DEBUG
2628
ThrowIfInvalidSubscription(subscription);

Runtime/SafeEventTwoParameters.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public void Invoke(T arg1, T2 arg2)
2020
if (subscriptions == null)
2121
return;
2222

23-
foreach (Action<T, T2> subscription in subscriptions)
23+
HashSet<Action<T, T2>> subscriptionsCopy = new HashSet<Action<T, T2>>(subscriptions);
24+
25+
foreach (Action<T, T2> subscription in subscriptionsCopy)
2426
{
2527
#if UNITY_EDITOR || DEBUG
2628
ThrowIfInvalidSubscription(subscription);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "net.tnrd.safeevent",
33
"displayName": "Safe Event",
4-
"version": "1.1.2",
4+
"version": "1.2.0",
55
"unity": "2019.1",
66
"description": "An event class that has extra checks to help prevent mistakes",
77
"keywords": [

0 commit comments

Comments
 (0)