GWTP - 清除演示者数据
GWTP - Clear Presenter Data
推荐的清除演示者数据的方法是什么?我想在登录时清除我的 UI。
作为当前问题的示例,我有一个用于收集表单数据的 NestedPresenter。有人可以注销,然后另一个用户可以在浏览器会话仍处于活动状态时重新登录,并且当显示表单时,先前用户的数据仍在显示。
有什么建议吗?
这在很大程度上取决于您在应用程序中使用的导航。如果您使用 PlaceManager 在几乎无状态的屏幕之间导航 - 覆盖 onReset
方法是我最推荐你的地方,因为每次导航将用户带到演示者 - 你的清晰代码将被执行。
onReset()
This happens at the end of each user's navigation request. For example
if one needs to execute some code when user navigates to a presenter
that's already bound, already added to a Slot, this is the method that
needs to be overriden. Be careful though, this is called often, so
nothing too heavy should be executed in this method.
清除视图,然后获取新模型。如果 onReset 对你来说太频繁了 - 坚持使用 onReveal()
然后
onReveal()
onReveal() will be called when the Presenter is being revealed. In
GWTP's vocabulary, this means when a Presenter is added to a Slot
Therefore, it doesn't necessarily mean that the object will be visible
in the DOM. See this issue to understand the disambiguition. This
should be overriden when one wants to update something on the
Presenter when it's about to be added to a Slot.
如果 onReveal 在您的情况下不起作用(您始终将演示者插入插槽 + 导航请求无关紧要) - 每次隐藏演示者时只需清除信息,通过覆盖 onHide()
推荐的清除演示者数据的方法是什么?我想在登录时清除我的 UI。
作为当前问题的示例,我有一个用于收集表单数据的 NestedPresenter。有人可以注销,然后另一个用户可以在浏览器会话仍处于活动状态时重新登录,并且当显示表单时,先前用户的数据仍在显示。
有什么建议吗?
这在很大程度上取决于您在应用程序中使用的导航。如果您使用 PlaceManager 在几乎无状态的屏幕之间导航 - 覆盖 onReset
方法是我最推荐你的地方,因为每次导航将用户带到演示者 - 你的清晰代码将被执行。
onReset()
This happens at the end of each user's navigation request. For example if one needs to execute some code when user navigates to a presenter that's already bound, already added to a Slot, this is the method that needs to be overriden. Be careful though, this is called often, so nothing too heavy should be executed in this method.
清除视图,然后获取新模型。如果 onReset 对你来说太频繁了 - 坚持使用 onReveal()
然后
onReveal()
onReveal() will be called when the Presenter is being revealed. In GWTP's vocabulary, this means when a Presenter is added to a Slot Therefore, it doesn't necessarily mean that the object will be visible in the DOM. See this issue to understand the disambiguition. This should be overriden when one wants to update something on the Presenter when it's about to be added to a Slot.
如果 onReveal 在您的情况下不起作用(您始终将演示者插入插槽 + 导航请求无关紧要) - 每次隐藏演示者时只需清除信息,通过覆盖 onHide()