GetCancellationTokenOnDestroy is moved to UnIRx.Async namespace

This commit is contained in:
Yoshifumi Kawai
2020-04-16 20:47:23 +09:00
parent a0ef75e797
commit 745de32006
5 changed files with 29 additions and 661 deletions

View File

@@ -3,6 +3,25 @@
using System.Threading;
using UnityEngine;
using UniRx.Async.Triggers;
namespace UniRx.Async
{
public static class UniTaskCancellationExtensions
{
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject)
{
return gameObject.GetAsyncDestroyTrigger().CancellationToken;
}
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this Component component)
{
return component.GetAsyncDestroyTrigger().CancellationToken;
}
}
}
namespace UniRx.Async.Triggers
{
@@ -36,18 +55,6 @@ namespace UniRx.Async.Triggers
return component.GetAsyncDestroyTrigger().OnDestroyAsync();
}
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject)
{
return gameObject.GetAsyncDestroyTrigger().CancellationToken;
}
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this Component component)
{
return component.GetAsyncDestroyTrigger().CancellationToken;
}
public static UniTask StartAsync(this GameObject gameObject)
{
return gameObject.GetAsyncStartTrigger().StartAsync();