Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewContext的疑问 #609

Closed
hunter2009 opened this issue Aug 3, 2016 · 3 comments
Closed

viewContext的疑问 #609

hunter2009 opened this issue Aug 3, 2016 · 3 comments

Comments

@hunter2009
Copy link

感觉esui里面的viewContext有点乱,有几点疑问:

  1. setProperties的时候为什么要支持对viewContext的更改,我理解viewContext应该不会轻易发生变更;
  2. 在initOptions的时候处理了一下,initViewContext的时候又处理了一下....是不是在实例化的时候只做一次处理比较好?
  3. 绑定,解绑,设置是不是放在viewContext里面做更好一点?
@otakustay
Copy link
Member

  1. 说得没错,viewContext应该是一个初始化时设置后续不能更改的属性,不过既然现状已经是这样了,为了保持兼容性不可能修改
  2. 事实上initOptions没有处理viewContext,是在setProperties里处理的,而setProperties不仅仅初始化时,运行期也会不断被调用,所以这个问题和1是一样的
  3. 暂时没理解具体指的是什么

@hunter2009
Copy link
Author

对于1,2:能否把这个流程放入组件的构造函数中初始化,然后在dispose的时候进行销毁,这样修改的话对当前流程会有影响吗?兼容性呢?
对于3:对于ViewContext的操作,是不是写一个类似ViewContextGroup或者ViewContextManager的管理器来管理viewContext集合,比如说组件切换视图视图时,通过这个Manager来管理;这样也可以支持实例级别的复用?(虽然几乎不存在这样场景...但是对复用性有追求,用不到,但是我们可以有...)

@otakustay
Copy link
Member

能否把这个流程放入组件的构造函数中初始化,然后在dispose的时候进行销毁,这样修改的话对当前流程会有影响吗?兼容性呢?

因为现在我们允许在组件初始化以后再改变viewContext(不可改变这个逻辑),所以肯定要在setProperties中支持修改,那么把这个流程放进初始化中去就是浪费

是不是写一个类似ViewContextGroup或者ViewContextManager的管理器来管理viewContext集合,比如说组件切换视图视图时,通过这个Manager来管理

现在的ViewContext本身就是这个Manager,提供了get等方法获取不同的ViewContext实例

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants