Skip to content

Commit ea68802

Browse files
committed
refactoring dotnet events
1 parent b6b9292 commit ea68802

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/ElectronNET.API/API/NativeTheme.cs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading.Tasks;
33
using ElectronNET.API.Entities;
44
using ElectronNET.API.Extensions;
5+
using ElectronNET.Common;
56

67
namespace ElectronNET.API
78
{
@@ -183,28 +184,8 @@ public Task<bool> ShouldUseInvertedColorSchemeAsync()
183184
/// </summary>
184185
public event Action Updated
185186
{
186-
add
187-
{
188-
if (_updated == null)
189-
{
190-
BridgeConnector.Socket.On("nativeTheme-updated" + GetHashCode(), () =>
191-
{
192-
_updated();
193-
});
194-
195-
BridgeConnector.Socket.Emit("register-nativeTheme-updated-event", GetHashCode());
196-
}
197-
_updated += value;
198-
}
199-
remove
200-
{
201-
_updated -= value;
202-
203-
if (_updated == null)
204-
{
205-
BridgeConnector.Socket.Off("nativeTheme-updated" + GetHashCode());
206-
}
207-
}
187+
add => ApiEventManager.AddEventWithSuffix("nativeTheme-updated", GetHashCode(), _updated, value);
188+
remove => ApiEventManager.RemoveEvent("nativeTheme-updated", GetHashCode(), _updated, value);
208189
}
209190

210191
private event Action _updated;

0 commit comments

Comments
 (0)