简体   繁体   English

嵌套视图的演示者未初始化且无法处理其视图的事件

[英]Nested View's Presenter not getting initialized and not being able to handle its view's events

I am facing an issue, when I do inject a nested view into my base view's constructor using @inject. 我确实使用@inject将嵌套视图注入到基本视图的构造函数中时遇到了一个问题。 I am not able to handle the nested view's events in it own presenter. 我无法在其自己的演示者中处理嵌套视图的事件。 Because of which I need to handle them in the Base View's presenter. 因此,我需要在基本视图的演示者中处理它们。 I have 2 view and their respective presenter's : AppBaseView - AppBasePresenter; 我有2个视图及其各自的演示者:AppBaseView-AppBasePresenter; LoginView - LoginPresenter. LoginView-LoginPresenter。 I @inject LoginView into the AppBaseView. 我将LoginView注入AppBaseView中。 Now that I have to handle the Login Button event, I am not able to do so in the LoginPresenter, but need to handle it in the AppBasePresenter. 现在,我必须处理Login Button事件,我无法在LoginPresenter中进行处理,但是需要在AppBasePresenter中进行处理。 No idea why does that happen. 不知道为什么会这样。 Am I missing anything? 我有什么想念的吗? Any light on this issue would be higly appreciated. 在这个问题上的任何亮光将不胜感激。

Thanks. 谢谢。

If you are trying to inject the same view into multiple classes, remember that you have to mark it as @Singleton , or otherwise ensure that both classes receive the same instance. 如果试图将同一视图注入多个类,请记住必须将其标记为@Singleton ,否则请确保两个类都接收相同的实例。 By default Guice and Gin create a brand new instance every time you inject a class. 默认情况下,每次插入类时,Guice和Gin都会创建一个全新的实例。 It's hard to tell from your description, but you might be adding an event listener to an instance that the presenter owns and then displaying a different instance in your application. 从描述中很难看出来,但是您可能要向演示者拥有的实例添加事件侦听器,然后在应用程序中显示另一个实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM