-
Notifications
You must be signed in to change notification settings - Fork 0
/
BubbleSignal.cs
54 lines (43 loc) · 1.35 KB
/
BubbleSignal.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#if UNITY_5 || UNITY_5_3_OR_NEWER
using UnityEngine;
//TargetDispatch and Dispatch must be renabled
namespace Svelto.UI.Comms.SignalChain
{
public class BubbleSignal<T>
{
SignalChain _signalChain;
public BubbleSignal (Transform node)
{
Transform root = node;
while (root != null && root.GetComponent<T>() == null)
root = root.parent;
DesignByContract.Check.Assert(root != null, "Error: constructed a bubble signal where no root was found. this bubble signal will not function correctly");
_signalChain = new SignalChain(root);
}
public void Dispatch<M>()
{
_signalChain.Broadcast<M>();
}
public void Dispatch<M>(M notification)
{
_signalChain.Broadcast(notification);
}
public void DeepDispatch<M>()
{
_signalChain.DeepBroadcast<M>();
}
public void DeepDispatch<M>(M notification)
{
_signalChain.DeepBroadcast(notification);
}
public void TargetedDispatch<M>()
{
_signalChain.Send<M>();
}
public void TargetedDispatch<M>(M notification)
{
_signalChain.Send(notification);
}
}
}
#endif