Skip to content

Commit

Permalink
Merge pull request #11 from techno-dwarf-works/feature/refactoring
Browse files Browse the repository at this point in the history
Version 0.0.8
  • Loading branch information
OpOpYaDev committed Apr 21, 2024
1 parent 9e5b191 commit a91fc3e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
7 changes: 3 additions & 4 deletions Runtime/BetterLocators.Runtime.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"name": "BetterLocators.Runtime",
"rootNamespace": "Better.Locators.Runtime",
"references": [
"GUID:01df13aca8d01e24a911bcc3e8277031",
"GUID:8bd4b41f8da90144d9006c4d926c9679",
"GUID:35101f455c979e94c9a0a4793484b7fd",
"GUID:1c5574afb40e5fe4ca9e9c156009297b"
"GUID:1c5574afb40e5fe4ca9e9c156009297b",
"GUID:8bd4b41f8da90144d9006c4d926c9679"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand All @@ -17,7 +16,7 @@
"versionDefines": [
{
"name": "com.tdw.better.services",
"expression": "0.1.0",
"expression": "0.0.4",
"define": "BETTER_SERVICES"
}
],
Expand Down
4 changes: 4 additions & 0 deletions Runtime/Installers/Services/MonoServiceInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#if BETTER_SERVICES
using System;
using Better.Services.Runtime;
using UnityEngine;

namespace Better.Locators.Runtime.Installers
{
[Serializable]
public class MonoServicesInstaller : ServicesInstaller<MonoService>
{
[SerializeField] private MonoService[] _services;

protected override MonoService[] Services => _services;
}
}
#endif
6 changes: 6 additions & 0 deletions Runtime/Installers/Services/PocoServicesInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#if BETTER_SERVICES
using System;
using Better.Attributes.Runtime.Select;
using Better.Services.Runtime;
using UnityEngine;

namespace Better.Locators.Runtime.Installers
{
[Serializable]
public class PocoServicesInstaller : ServicesInstaller<PocoService>
{
[Select]
[SerializeReference] private PocoService[] _services;

protected override PocoService[] Services => _services;
}
}
#endif
17 changes: 9 additions & 8 deletions Runtime/Installers/Services/ServicesInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Better.Attributes.Runtime.Select;
using Better.Commons.Runtime.Extensions;
using Better.Services.Runtime.Interfaces;
using UnityEngine;
Expand All @@ -13,31 +14,31 @@ namespace Better.Locators.Runtime.Installers
public abstract class ServicesInstaller<TDerivedService> : Installer
where TDerivedService : class, IService
{
[SerializeReference] private TDerivedService[] _services;
protected abstract TDerivedService[] Services { get; }

public override async Task InstallBindingsAsync(CancellationToken cancellationToken)
{
await _services.Select(x => x.InitializeAsync(cancellationToken)).WhenAll();
await Services.Select(x => x.InitializeAsync(cancellationToken)).WhenAll();

if (cancellationToken.IsCancellationRequested)
{
Debug.LogError("Operation was cancelled");
return;
}

for (int i = 0; i < _services.Length; i++)
for (int i = 0; i < Services.Length; i++)
{
ServiceLocator.Register(_services[i]);
ServiceLocator.Register(Services[i]);
}

await _services.Select(x => x.PostInitializeAsync(cancellationToken)).WhenAll();
await Services.Select(x => x.PostInitializeAsync(cancellationToken)).WhenAll();
}

public override void UninstallBindings()
{
for (int i = 0; i < _services.Length; i++)
for (int i = 0; i < Services.Length; i++)
{
ServiceLocator.Unregister<IService>(_services[i]);
ServiceLocator.Unregister<IService>(Services[i]);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "com.tdw.better.locators",
"displayName": "Better Locators",
"version": "0.1.0",
"name": "com.tdw.better.locator",
"displayName": "Better Locator",
"version": "0.0.8",
"unity": "2021.3",
"description": " ",
"dependencies": {
"com.tdw.better.internal.core": "0.0.2",
"com.tdw.better.commons": "0.0.2",
"com.uurha.betterattributes": "3.1.0"
"com.tdw.better.commons": "0.0.4",
"com.uurha.betterattributes": "3.1.1"
},
"author": {
"name": "Better Plugins",
"url": "https://github.com/techno-dwarf-works"
},
"changelogUrl": "https://github.com/techno-dwarf-works/better-locators",
"documentationUrl": "https://github.com/techno-dwarf-works/better-locators/tree/main#readme",
"changelogUrl": "https://github.com/techno-dwarf-works/better-locator",
"documentationUrl": "https://github.com/techno-dwarf-works/better-locator/tree/main#readme",
"license": "MIT",
"licensesUrl": "https://github.com/techno-dwarf-works/better-locators/blob/main/LICENSE",
"licensesUrl": "https://github.com/techno-dwarf-works/better-locator/blob/main/LICENSE",
"keywords": [
"locators",
"reference management",
Expand Down

0 comments on commit a91fc3e

Please sign in to comment.