@@ -41,25 +41,29 @@ type ContextType = {
41
41
getGlobalState ?: ( ) => Record < any , any > ;
42
42
/** 更新全局状态 */
43
43
updateGlobalState ?: ( newState : any ) => void ;
44
- /** 存储当前节点的数据,不具有响应性 **/
44
+ /** 存储当前节点的数据,不具有响应性, 可能不是最新的值 **/
45
45
staticVar ?: Record < string | number , any > ;
46
+ /** 获取当前节点的静态变量,不具有响应性 */
46
47
getStaticVar ?: ( ) => Record < string , any > ;
47
- getStaticVarById ?: ( nodeId : string ) => Record < string , any > ;
48
+ getStaticVarById ?: ( /** 节点 id */ nodeId : string ) => Record < string , any > ;
48
49
methods ?: Record < string , ( ...arg : any ) => any > ;
50
+ /** 获取当前节点的方法,不具有响应性 */
49
51
getMethods ?: ( ) => Record < string , ( ...arg : any ) => any > ;
50
- getMethodsById ?: ( nodeId : string ) => Record < string , ( ...arg : any ) => any > ;
52
+ getMethodsById ?: ( /** 节点 id */ nodeId : string ) => Record < string , ( ...arg : any ) => any > ;
51
53
/** 当前节点状态 **/
52
54
state ?: Record < any , any > ;
53
55
/** 更新当前节点状态 */
54
56
updateState ?: ( newState : any ) => void ;
57
+ /** 获取当前节点状态最新 */
55
58
getState ?: ( ) => Record < any , any > ;
56
- getStateById ?: ( nodeId : string ) => Record < any , any > ;
57
- updateStateById ?: ( nodeId : string , newState : Record < any , any > ) => void ;
59
+ getStateById ?: ( /** 节点 id */ nodeId : string ) => Record < any , any > ;
60
+ updateStateById ?: ( /** 节点 id */ nodeId : string , newState : Record < any , any > ) => void ;
61
+ /** 一次性返回最新的 state 以及更新的方法 */
58
62
getStateObj ?: ( ) => {
59
63
state ?: Record < any , any > ;
60
64
updateState ?: ( newState : any ) => void ;
61
65
} ;
62
- getStateObjById ?: ( nodeId : string ) => {
66
+ getStateObjById ?: ( /** 节点 id */ nodeId : string ) => {
63
67
state ?: Record < any , any > ;
64
68
updateState ?: ( newState : any ) => void ;
65
69
} ;
@@ -73,14 +77,20 @@ type ContextType = {
73
77
> ;
74
78
/** 循环数据 */
75
79
loopData ?: Record < any , any > ;
76
- /** 组件节点的 Ref */
77
- nodeRefs ?: { get : ( nodeId : string ) => any } ;
80
+ /** 组件节点的 Ref, 可以通过 current 直接调用节点提供的方法,需要判断是否在存在 */
81
+ nodeRefs ?: { get : ( /** 节点 id */ nodeId : string ) => { current ?: any } } ;
82
+ /** 运行时全局的 store 管理 */
78
83
storeManager ?: StoreManager ;
79
84
/** 第三方辅助库 */
80
85
thirdLibs ?: Record < string , any > ;
81
86
} ;
82
87
83
88
/** 渲染上下文 */
84
89
declare global {
90
+ /** 运行时上下文
91
+ * @deprecated
92
+ */
85
93
const $$context : ContextType ;
94
+ /** 运行时上下文 */
95
+ const $CTX : ContextType ;
86
96
}
0 commit comments