UniRx 에셋 추가

This commit is contained in:
Mingu Kim
2025-06-02 00:27:36 +09:00
parent 915f292d7d
commit 8a54d47b56
510 changed files with 42973 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using System;
namespace UniRx.Diagnostics
{
public static class ObservableDebugExtensions
{
/// <summary>
/// Debug helper of observbale stream. Works for only DEBUG symbol.
/// </summary>
public static IObservable<T> Debug<T>(this IObservable<T> source, string label = null)
{
#if DEBUG
var l = (label == null) ? "" : "[" + label + "]";
return source.Materialize()
.Do(x => UnityEngine.Debug.Log(l + x.ToString()))
.Dematerialize()
.DoOnCancel(() => UnityEngine.Debug.Log(l + "OnCancel"))
.DoOnSubscribe(() => UnityEngine.Debug.Log(l + "OnSubscribe"));
#else
return source;
#endif
}
/// <summary>
/// Debug helper of observbale stream. Works for only DEBUG symbol.
/// </summary>
public static IObservable<T> Debug<T>(this IObservable<T> source, UniRx.Diagnostics.Logger logger)
{
#if DEBUG
return source.Materialize()
.Do(x => logger.Debug(x.ToString()))
.Dematerialize()
.DoOnCancel(() => logger.Debug("OnCancel"))
.DoOnSubscribe(() => logger.Debug("OnSubscribe"));
#else
return source;
#endif
}
}
}