@izumisy-tailor/tailor-data-viewer 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -69,6 +69,7 @@ export class TableDataStore {
|
|
|
69
69
|
private config: TableDataStoreConfig;
|
|
70
70
|
private client: ReturnType<typeof createGraphQLClient>;
|
|
71
71
|
private abortController: AbortController | null = null;
|
|
72
|
+
private hasFetchedInitially = false;
|
|
72
73
|
|
|
73
74
|
constructor(config: TableDataStoreConfig) {
|
|
74
75
|
this.config = config;
|
|
@@ -86,16 +87,21 @@ export class TableDataStore {
|
|
|
86
87
|
},
|
|
87
88
|
cursorHistory: [],
|
|
88
89
|
};
|
|
89
|
-
|
|
90
|
-
// Start initial fetch immediately (no useEffect needed)
|
|
91
|
-
this.fetch();
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
/**
|
|
95
93
|
* Subscribe to state changes (required by useSyncExternalStore)
|
|
94
|
+
* Triggers initial fetch on first subscription.
|
|
96
95
|
*/
|
|
97
96
|
subscribe = (listener: () => void): (() => void) => {
|
|
98
97
|
this.listeners.add(listener);
|
|
98
|
+
|
|
99
|
+
// Trigger initial fetch when first listener subscribes
|
|
100
|
+
// This ensures notify() will reach the listener
|
|
101
|
+
if (!this.hasFetchedInitially) {
|
|
102
|
+
this.hasFetchedInitially = true;
|
|
103
|
+
this.fetch();
|
|
104
|
+
}
|
|
99
105
|
return () => {
|
|
100
106
|
this.listeners.delete(listener);
|
|
101
107
|
};
|
|
@@ -129,7 +129,7 @@ export function useTableData(
|
|
|
129
129
|
|
|
130
130
|
// Create store synchronously via useMemo
|
|
131
131
|
// Store is recreated when any relevant config changes
|
|
132
|
-
//
|
|
132
|
+
// Initial fetch is triggered when useSyncExternalStore subscribes
|
|
133
133
|
const store = useMemo(() => {
|
|
134
134
|
// Destroy previous store if exists
|
|
135
135
|
if (storeRef.current) {
|