mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-30 20:33:43 +01:00
Test subscription like before but without primary constructor.
This commit is contained in:
parent
d9bd05c9ec
commit
6b5321dad8
1 changed files with 11 additions and 17 deletions
|
|
@ -5,7 +5,7 @@ using Penumbra.Services;
|
|||
|
||||
namespace Penumbra.Api.Api;
|
||||
|
||||
public sealed class PluginStateApi : IPenumbraApiPluginState, IApiService, IDisposable
|
||||
public class PluginStateApi : IPenumbraApiPluginState, IApiService
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
private readonly CommunicatorService _communicator;
|
||||
|
|
@ -14,14 +14,6 @@ public sealed class PluginStateApi : IPenumbraApiPluginState, IApiService, IDisp
|
|||
{
|
||||
_config = config;
|
||||
_communicator = communicator;
|
||||
_communicator.ModDirectoryChanged.Subscribe(OnModDirectoryChanged, Communication.ModDirectoryChanged.Priority.Api);
|
||||
_communicator.EnabledChanged.Subscribe(OnEnabledChanged, EnabledChanged.Priority.Api);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_communicator.ModDirectoryChanged.Unsubscribe(OnModDirectoryChanged);
|
||||
_communicator.EnabledChanged.Unsubscribe(OnEnabledChanged);
|
||||
}
|
||||
|
||||
public string GetModDirectory()
|
||||
|
|
@ -30,16 +22,18 @@ public sealed class PluginStateApi : IPenumbraApiPluginState, IApiService, IDisp
|
|||
public string GetConfiguration()
|
||||
=> JsonConvert.SerializeObject(_config, Formatting.Indented);
|
||||
|
||||
public event Action<string, bool>? ModDirectoryChanged;
|
||||
public event Action<string, bool>? ModDirectoryChanged
|
||||
{
|
||||
add => _communicator.ModDirectoryChanged.Subscribe(value!, Communication.ModDirectoryChanged.Priority.Api);
|
||||
remove => _communicator.ModDirectoryChanged.Unsubscribe(value!);
|
||||
}
|
||||
|
||||
public bool GetEnabledState()
|
||||
=> _config.EnableMods;
|
||||
|
||||
public event Action<bool>? EnabledChange;
|
||||
|
||||
private void OnModDirectoryChanged(string modDirectory, bool valid)
|
||||
=> ModDirectoryChanged?.Invoke(modDirectory, valid);
|
||||
|
||||
private void OnEnabledChanged(bool value)
|
||||
=> EnabledChange?.Invoke(value);
|
||||
public event Action<bool>? EnabledChange
|
||||
{
|
||||
add => _communicator.EnabledChanged.Subscribe(value!, EnabledChanged.Priority.Api);
|
||||
remove => _communicator.EnabledChanged.Unsubscribe(value!);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue