Skip to content

Commit 23a8142

Browse files
committed
cleanup
1 parent 5a34347 commit 23a8142

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

Scripts/SignalListener.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityEngine;
1+
using System.Diagnostics.CodeAnalysis;
2+
using UnityEngine;
23
using UnityEngine.Events;
34

45
namespace Signals
@@ -44,14 +45,17 @@ public bool InvokeImmediately
4445

4546
void AddListenerToSignal()
4647
{
47-
if (_signal)
48+
if (_signal != null)
4849
{
4950
_signal.AddListener(_onUpdated.Invoke);
5051
if (_invokeImmediately) _onUpdated.Invoke();
5152
}
5253
}
5354

54-
void RemoveListenerFromSignal() => _signal?.RemoveListener(_onUpdated.Invoke);
55+
void RemoveListenerFromSignal()
56+
{
57+
if(_signal != null) _signal.RemoveListener(_onUpdated.Invoke);
58+
}
5559
}
5660

5761

@@ -108,6 +112,10 @@ void AddListenerToSignal()
108112
}
109113
}
110114

111-
void RemoveListenerFromSignal() => _signal?.RemoveListener(_onUpdated.Invoke);
115+
[SuppressMessage("Style", "IDE0031:Use null propagation", Justification = "_signal is a Unity Object")]
116+
void RemoveListenerFromSignal()
117+
{
118+
if (_signal != null) _signal.RemoveListener(_onUpdated.Invoke);
119+
}
112120
}
113121
}

Scripts/ValueReference.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,7 @@ public T LocalValue
4747
/// <summary>The <see cref="Signal.Value"/> of the <see cref="Signal"/> if <see cref="UseLocalValue"/> is false, the <see cref="LocalValue"/> otherwise.</summary>
4848
public T Value
4949
{
50-
get
51-
{
52-
if (_useLocalValue)
53-
{
54-
return _localValue;
55-
}
56-
else
57-
{
58-
if (_signal == null) throw new NullReferenceException();
59-
return _signal.Value;
60-
}
61-
}
50+
get => _useLocalValue ? _localValue : _signal == null ? throw new NullReferenceException() : _signal.Value;
6251
set
6352
{
6453
if (_useLocalValue)

0 commit comments

Comments
 (0)