forked from zxl/LaboratoryProtection
32 lines
663 B
C#
32 lines
663 B
C#
|
using System;
|
||
|
|
||
|
using UniRx;
|
||
|
|
||
|
using UnityEngine.Events;
|
||
|
|
||
|
namespace PMaker.Reactive
|
||
|
{
|
||
|
public static class DomainStream<T>
|
||
|
{
|
||
|
private static ReactiveProperty<T> _handle = new ReactiveProperty<T>();
|
||
|
|
||
|
public static void Publish(T stream)
|
||
|
{
|
||
|
_handle.Value = stream;
|
||
|
}
|
||
|
|
||
|
public static IObservable<T> Subscribe()
|
||
|
{
|
||
|
return _handle;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static class DomainStreamUnityEventExtension
|
||
|
{
|
||
|
public static void Binding<T>(this UnityEvent unityEvent, T stream)
|
||
|
{
|
||
|
unityEvent.AddListener(() => { DomainStream<T>.Publish(stream); });
|
||
|
}
|
||
|
}
|
||
|
}
|