Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a specific reason to fire Signals based on static type ? #652

Open
FriedrichWessel opened this issue Aug 8, 2019 · 0 comments
Open

Comments

@FriedrichWessel
Copy link

Hello Zenject team,

I started working with the new Signalbus and stumbled over the following
Fire a signal with:

_signalBus.Fire(new SpecialSignal()) works fine.

But if I move the creation to a factory:

SignalFactory { InterfaceForSignal Create(){return new SpecialSignal();} }

The signal is fired with the static type: InterfaceForSignal instead of the dynamic type SpecialSignalwhich of course means that a subscribe does not work in the Special type.

From what I see in the bus code it looks like the typeof() instead of GetType() here is the reason (SignalBus line: 77):

public void FireId<TSignal>(object identifier, TSignal signal)
        {
            // Do this before creating the signal so that it throws if the signal was not declared
            var declaration = GetDeclaration(typeof(signal.GetType), identifier, true);

            declaration.Fire(signal);
        }

So question is: Is there a specific reason to fire based on the static type - or can I change that to GetType and open a PR ?

Best regards and thanks for your help
Friedrich

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant