提交 8a6a2a34 编写于 作者: D dolymood

docs(singleton): about create-api singleton changes

上级 8a4a05c7
## Singleton Pattern
You need to take the singleton and multiton pattern of components into account when invoking the component by API. If the component is singleton, then there will be only one instance when instantiating it multiple times, and there is only one corresponding view layer; If the component is multiton, then a new instance will be created each time you instantiate it, and there are multiple corresponding view layers which don't affect each other.
You need to take the singleton and multiton pattern of components into account when invoking the component by API.
- After 1.11
If the component is singleton, then there will be only one instance when instantiating it multiple times **in same component**, and there is only one corresponding view layer; If the component is multiton, then a new instance will be created each time you instantiate it, and there are multiple corresponding view layers which don't affect each other.
- Below 1.11
If the component is singleton, then there will be only one instance when instantiating it multiple times, and there is only one corresponding view layer; If the component is multiton, then a new instance will be created each time you instantiate it, and there are multiple corresponding view layers which don't affect each other.
The components that are involved with api-invoking in cube-ui are all popups. Frequently used ones among them are listed below:
......
## 单例模式
通过 API 调用组件的时候,需要涉及到组件的单例、多例模式。如果说组件是单例的,在多次实例化的时候,只有一个实例,对应的视图层也只存在一份;如果说组件是多例的,那么每次实例化的时候都会产生一个新的实例,且对应的视图也是有多份的,它们之间互不影响。
通过 API 调用组件的时候,需要涉及到组件的单例、多例模式。
- 1.11 版本之后
单例是相对于某一个组件上下文的,如果说组件是单例的,在同一个组件内多次实例化的时候,只有一个实例,对应的视图层也只存在一份;如果说组件是多例的,那么每次实例化的时候都会产生一个新的实例,且对应的视图也是有多份的,它们之间互不影响。
- 1.11 版本之前
如果说组件是单例的,在多次实例化的时候,只有一个实例,对应的视图层也只存在一份;如果说组件是多例的,那么每次实例化的时候都会产生一个新的实例,且对应的视图也是有多份的,它们之间互不影响。
在 cube-ui 中涉及到 API 调用的组件都是弹层类,经常使用的如下:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册