将 UI 数据存储在 Repository 而不是 SharedViewModel 中是最佳实践吗?
假设我有 3 个屏幕(3 个片段),都有自己的表单输入字段,最后一个屏幕将显示之前收集的所有表单数据,因此这些表单数据需要在到达最后一个屏幕之前存储在某个地方。
而且这些表单数据不需要持久化,用户使用此功能时必须重新从头开始填写表单。
我应该将每个片段的数据存储到 SharedViewModel 还是 Repository 中?
它适用于两种解决方案,但我正在尝试遵循 mvvm + clean 架构,并且我正在考虑在这种情况下遵循的最佳实践是什么。
任何建议将不胜感激。
太感谢了
Let's say I have 3 screens (3 fragments) with its own form input fields and the last screen will display all form data that collected before so these form data need to be stored at somewhere before reaching the last screen.
And these form data no need to be persisted, users have to start from the beginning again to fill the form when coming to this feature.
Should I store this data from each fragment into SharedViewModel or Repository?.
It works on both solutions but I'm trying to follow mvvm + clean architecture and I'm thinking about what is the best practice to follow in this scenario.
Any suggestions would be greatly appreciated.
Thank you so much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你可以使用 SharedViewModel 。在您的情况下使用存储库是不必要的。
I think you can use SharedViewModel. Using a repository in your case is unnecessary.