@@ -49,6 +49,45 @@ public int NumSubscribers
4949 get { return _subscriptionMap . Count ; }
5050 }
5151
52+
53+ //AbstractFire Works like a normal Fire but it fires the interface types of the signal too
54+ public void AbstractFire < TSignal > ( ) where TSignal : new ( ) => AbstractFire ( new TSignal ( ) ) ;
55+ public void AbstractFire < TSignal > ( TSignal signal ) => AbstractFireId ( null , signal ) ;
56+ public void AbstractFireId < TSignal > ( object identifier , TSignal signal )
57+ {
58+ // Do this before creating the signal so that it throws if the signal was not declared
59+ Type tt = typeof ( TSignal ) ;
60+ var declaration = GetDeclaration ( tt , identifier , true ) ;
61+ declaration . Fire ( signal ) ;
62+
63+ //Everything is fired like a normal signal and then this method Fires the signal with the interface types
64+ //Its async because its faster and doesn't blocks the main thread when you fire signals
65+ //Tested with a loop of 1 million iteration and this is the faster way of getting the interfaces fast
66+ FireSignalGetDeclarationForInterfacesAsync ( identifier , signal , tt ) ;
67+ }
68+
69+ //Fire and forget methof for the task
70+ public async void FireSignalGetDeclarationForInterfacesAsync < TSignal > ( object identifier , TSignal signal , Type type )
71+ {
72+ await Task . Run ( ( ) => FireSignalGetDeclarationForInterfacesTask ( identifier , signal , type ) ) ;
73+ }
74+ public async Task FireSignalGetDeclarationForInterfacesTask < TSignal > ( object identifier , TSignal signal , Type type )
75+ {
76+ //The asynchronous iteration for reflection
77+ Type [ ] interfaces = type . GetInterfaces ( ) ;
78+ int numOfInterfaces = interfaces . Length ;
79+ for ( int i = 0 ; i < numOfInterfaces ; i ++ )
80+ {
81+ //To make this work you should also declare the signal's interfaces, but they are automatically declared
82+ //if you do "DeclareSignalWithInterfaces<TSignal>()" in the container
83+ //Go to SignalExtensions.cs for more info
84+ var declaration = GetDeclaration ( interfaces [ i ] , identifier , true ) ;
85+ declaration . Fire ( signal ) ;
86+ }
87+ }
88+
89+
90+
5291 public void LateDispose ( )
5392 {
5493 if ( _settings . RequireStrictUnsubscribe )
0 commit comments