We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 13e771a commit 95223f6Copy full SHA for 95223f6
libs/CKUI.lib.js
@@ -1,7 +1,7 @@
1
// ==UserScript==
2
// @name CKUI
3
// @namespace ckylin-script-lib-ckui
4
-// @version 2.4.5
+// @version 2.4.6
5
// @description A modern, dependency-free UI library for Tampermonkey scripts
6
// @match http://*
7
// @match https://*
@@ -85,8 +85,18 @@ if (typeof unsafeWindow === 'undefined' || !unsafeWindow) {
85
}
86
87
88
- subscribe(callback) {
+ subscribe(callback, immediate = true) {
89
this._subscribers.push(callback);
90
+
91
+ // 立即执行一次回调以同步初始值
92
+ if (immediate) {
93
+ try {
94
+ callback(this._value);
95
+ } catch (e) {
96
+ console.error('[CKUI] Reactive callback error:', e);
97
+ }
98
99
100
return () => {
101
this._subscribers = this._subscribers.filter(cb => cb !== callback);
102
};
0 commit comments