我应该去做什么架构,这不是一个不好的架构
我有一个大表单要显示,无法在单个页面上显示。所以我们所做的是将其分为 7 个部分,每个部分由 1 个片段组成,所有这些片段都使用选项卡布局和视图分页器进行导航。每个片段都有自己的视图模型,以便访问数据绑定。现在的问题是我们可以随机选择任何选项卡并更新数据,因此我们需要一个中心位置来存储该数据并更新它,但数据是复杂的 json 模型,因此无法轻松存储在数据库中,还有其他选择吗去追求?
I have a large form to show which can not be displayed on a single page. so what we did is divide it into 7 part, each part consist of 1 fragment and all those fragments are navigated using tab layouts and view pager. each of those fragments have their on view model in order to access data binding . Now the problem is we can randomly select any tab and update data so we need a central location to store that data and update it, but the data is complex json model so can't be stored in a database easily, is there any other option to pursue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要集中数据,请使用活动示波器的ViewModel。
在下面的片段中初始化视图模型:
或
这样,您可以将所有数据操作或单个位置的完整组合成集中。
If you want to centralize the data then use Activity Scoped ViewModel.
Initialized your viewmodel in your fragments as below:
OR
This way you can centralize all your data manipulation or form completion at single place.