Skip to content

Commit

Permalink
Update README.md and LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
uurha committed Apr 10, 2024
1 parent 10548e7 commit 1ec5735
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Editor/BetterServices.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BetterServices.Editor",
"rootNamespace": "Better.Services",
"rootNamespace": "Better.Services.EditorAddons",
"references": [
"GUID:1c5574afb40e5fe4ca9e9c156009297b"
],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Better Services

[![openupm](https://img.shields.io/npm/v/com.tdw.betterservices?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tdw.betterservices/)
[![openupm](https://img.shields.io/npm/v/com.tdw.better.services?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tdw.better.services/)

This plugins provides basic implementation for services pattern

Expand Down
6 changes: 3 additions & 3 deletions Runtime/BetterServices.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "BetterServices.Runtime",
"rootNamespace": "Better.Services",
"rootNamespace": "Better.Services.Runtime",
"references": [
"GUID:441b78e90a9cf724ab41c6eed8c0b93d",
"GUID:a59e3daedde9ca94bba45364d4ead25f"
"GUID:8bd4b41f8da90144d9006c4d926c9679"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand All @@ -15,7 +15,7 @@
"versionDefines": [
{
"name": "com.uurha.bettervalidation",
"expression": "1.0.4",
"expression": "1.6.0",
"define": "BETTER_VALIDATION"
}
],
Expand Down
9 changes: 3 additions & 6 deletions Runtime/Services/MonoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ protected virtual void Awake()

async Task IService.InitializeAsync(CancellationToken cancellationToken)
{
Debug.Log($"[{GetType().Name}] {nameof(IService.InitializeAsync)}");

if (Initialized)
{
Debug.LogError($"[{GetType().Name}] {nameof(IService.InitializeAsync)}: already initialized");
Debug.LogError("Service already initialized");
return;
}

Expand All @@ -38,18 +36,17 @@ async Task IService.InitializeAsync(CancellationToken cancellationToken)
}

Initialized = true;
Debug.Log("Service initialized");
}

Task IService.PostInitializeAsync(CancellationToken cancellationToken)
{
if (!Initialized)
{
Debug.LogError($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}: not initialized");
Debug.LogError("Service must be initialized");
return Task.CompletedTask;
}

Debug.Log($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}");

var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(DestroyCancellationToken, cancellationToken);
cancellationToken = linkedTokenSource.Token;

Expand Down
15 changes: 8 additions & 7 deletions Runtime/Services/PocoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Better.Services.Runtime.Interfaces;
using UnityEngine;

#if BETTER_VALIDATION
using Better.Validation.Runtime.Attributes;
#endif
Expand All @@ -16,28 +17,27 @@ public abstract class PocoService : IService

async Task IService.InitializeAsync(CancellationToken cancellationToken)
{
Debug.Log($"[{GetType().Name}] {nameof(IService.InitializeAsync)}");

if (Initialized)
{
Debug.LogError($"[{GetType().Name}] {nameof(IService.InitializeAsync)}: already initialized");
Debug.LogError("Service already initialized");
return;
}

Initialized = true;
await OnInitializeAsync(cancellationToken);
Initialized = !cancellationToken.IsCancellationRequested;

Debug.Log("Service initialized");
}

Task IService.PostInitializeAsync(CancellationToken cancellationToken)
{
if (!Initialized)
{
Debug.LogError($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}: not initialized");
Debug.LogError("Service must be initialized");
return Task.CompletedTask;
}

Debug.Log($"[{GetType().Name}] {nameof(IService.PostInitializeAsync)}");
return OnPostInitializeAsync(cancellationToken);
}

Expand All @@ -49,7 +49,7 @@ Task IService.PostInitializeAsync(CancellationToken cancellationToken)
public abstract class PocoService<TSettings> : PocoService where TSettings : ScriptableObject
{
#if BETTER_VALIDATION
[NotNull]
[NotNull]
#endif
[SerializeField] private TSettings _settings;

Expand All @@ -59,7 +59,8 @@ protected override Task OnInitializeAsync(CancellationToken cancellationToken)
{
if (Settings == null)
{
throw new NullReferenceException($"[{GetType().Name}] {nameof(OnInitializeAsync)}: {nameof(Settings)} cannot be null");
var exception = new NullReferenceException(nameof(Settings));
Debug.LogException(exception);
}

return Task.CompletedTask;
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "com.tdw.better.services",
"displayName": "Better Services",
"version": "0.0.4",
"version": "0.1.0",
"unity": "2021.3",
"description": " ",
"dependencies": {
"com.tdw.better.internal.core": "0.0.2"
},
"author": {
"name": "Better Plugins",
"url": "https://github.com/techno-dwarf-works"
Expand Down

0 comments on commit 1ec5735

Please sign in to comment.