@@ -11,7 +11,7 @@ namespace Zenject
1111 public class SignalBus : ILateDisposable
1212 {
1313 readonly SignalSubscription . Pool _subscriptionPool ;
14- readonly Dictionary < BindingId , SignalDeclaration > _localDeclarationMap ;
14+ readonly Dictionary < BindingId , SignalDeclaration > _localDeclarationMap = new Dictionary < BindingId , SignalDeclaration > ( ) ;
1515 readonly SignalBus _parentBus ;
1616 readonly Dictionary < SignalSubscriptionId , SignalSubscription > _subscriptionMap = new Dictionary < SignalSubscriptionId , SignalSubscription > ( ) ;
1717 readonly ZenjectSettings . SignalSettings _settings ;
@@ -35,7 +35,14 @@ public SignalBus(
3535 _signalDeclarationFactory = signalDeclarationFactory ;
3636 _container = container ;
3737
38- _localDeclarationMap = signalDeclarations . ToDictionary ( x => x . BindingId , x => x ) ;
38+ signalDeclarations . ForEach ( x =>
39+ {
40+ if ( ! _localDeclarationMap . ContainsKey ( x . BindingId ) )
41+ {
42+ _localDeclarationMap . Add ( x . BindingId , x ) ;
43+ }
44+ else _localDeclarationMap [ x . BindingId ] . Subscriptions . AllocFreeAddRange ( x . Subscriptions ) ;
45+ } ) ;
3946 _parentBus = parentBus ;
4047 }
4148
@@ -57,15 +64,15 @@ public void AbstractFireId<TSignal>(object identifier, TSignal signal)
5764 {
5865 // Do this before creating the signal so that it throws if the signal was not declared
5966 Type signalType = typeof ( TSignal ) ;
67+ InternalFire ( signalType , signal , identifier , true ) ;
6068 var declaration = GetDeclaration ( signalType , identifier , true ) ;
6169 declaration . Fire ( signal ) ;
6270
6371 Type [ ] interfaces = signalType . GetInterfaces ( ) ;
6472 int numOfInterfaces = interfaces . Length ;
6573 for ( int i = 0 ; i < numOfInterfaces ; i ++ )
6674 {
67- declaration = GetDeclaration ( interfaces [ i ] , identifier , true ) ;
68- declaration . Fire ( signal ) ;
75+ InternalFire ( interfaces [ i ] , signal , identifier , true ) ;
6976 }
7077 }
7178
@@ -213,7 +220,7 @@ public IObservable<TSignal> GetStream<TSignal>()
213220
214221 public IObservable < object > GetStreamId ( Type signalType , object identifier )
215222 {
216- return GetDeclaration ( signalType , identifier , true ) . Stream ;
223+ return GetDeclaration ( new BindingId ( signalType , identifier ) ) . Stream ;
217224 }
218225
219226 public IObservable < object > GetStream ( Type signalType )
0 commit comments