什么是 UI 状态? [英] What is UI state?

查看:41
本文介绍了什么是 UI 状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 UI 状态?你能给我举个类似的例子吗?例如,它是指跟踪打开的标签页之类的东西吗?

What is UI state? Can you give me an example of something like that might be? Does it refer to things like keeping track of what tab is open for example?

推荐答案

我认为这个想法是 应用程序 具有状态,而 UI 反映该状态.

I think the idea is that the application has state, and the UI reflects that state.

所以当你的应用程序启动时,它会像下面这样

So when you app starts it goes like the following

1) 初始状态(应用已启动)
2) 加载初始数据(加载状态")
3) 准备好进行交互(就绪状态")

1) Initial state (app is started up)
2) Loads initial data ("loading state")
3) Is ready for interaction ("ready state")

现在假设用户通过打开表单开始交互.

Now lets say the user starts an interaction by opening a form.

4) 用户打开表单并进入('编辑表单状态')

4) User opens form and goes to ('editing form state')

用户可以取消或保存,所以现在状态不同了.如果取消

The user can cancel or save so now the states diverge. If cancel

5) 'editing form state'接收到cancel事件,放弃修改,回到Ready"状态

5) The 'editing form state' receives the cancel event, discards the changes, and goes back to "Ready"

如果保存

5) 应用程序进入正在保存"状态,然后在完成后返回就绪"或错误"

5) The app goes to "Saving" state, then when done goes back to "Ready" or "Error"

这种概念化的伟大之处在于它允许您的状态图"根据状态更新应用程序元素.例如,在加载"或保存"状态下,您可以屏蔽 UI 或禁用按钮.关键是视图不需要知道状态,它所做的只是坐在那里并被操纵.它是管理视图在任何给定时间做什么的状态代码.

The great thing about this conceptualization is that it allows your 'state chart' to update the application elements depending on the state. For example, in 'loading' or 'saving' states you can mask the UI or disable the buttons. The key point is that the views don't need to know about the state, all it does is sit around and be manipulated. Its the state code that manages what views are doing what at any given time.

请注意,UI 中的视图具有状态也是正确的.例如,按钮可以具有诸如mouseenter"、mouseexit"、clickdown"、clickup"、inactive"等状态.当 UI 中的自定义视图呈现不同时,可以认为它具有状态,具体取决于在它代表的数据上.

Note that is also correct for views in your UI to have state. For example, a button can have states like, 'mouseenter', 'mouseexit', 'clickdown', 'clickup', 'inactive', etc. A custom view in your UI can be considered to have states when it renders itself differently depending on the data it represents.

你可能想看看

http://www.wisdom.weizmann.ac.il/~harel/papers/Statecharts.pdf

这篇关于什么是 UI 状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆